List of usage examples for org.apache.commons.lang3.tuple Pair getLeft
public abstract L getLeft();
Gets the left element from this pair.
When treated as a key-value pair, this is the key.
From source file:com.addthis.hydra.job.store.CachedSpawnDataStore.java
public CachedSpawnDataStore(SpawnDataStore dataStore, long dataStoreCacheSize) { this.dataStore = dataStore; this.cache = CacheBuilder.newBuilder().weigher(new Weigher<Pair<String, String>, String>() { @Override//from w w w .java 2 s.c om public int weigh(Pair<String, String> key, String value) { int leftWeight = key.getLeft() != null ? key.getLeft().length() : 0; int rightWeight = key.getRight() != null ? key.getRight().length() : 0; // Multiply strlen by 2 (full width characters in java return 2 * (value.length() + leftWeight + rightWeight); } }).maximumWeight(dataStoreCacheSize).build(new CacheLoader<Pair<String, String>, String>() { @Override public String load(Pair<String, String> key) throws Exception { String path = key.getLeft(); String childId = key.getRight(); if (childId == null) { return CachedSpawnDataStore.this.dataStore.get(path); } else { return CachedSpawnDataStore.this.dataStore.getChild(path, childId); } } }); }
From source file:net.malisis.blocks.tileentity.SwapperTileEntity.java
private void storeState(int x, int y, int z, Pair<IBlockState, NBTTagCompound> state) { states[x][y][z] = state.getLeft(); tileEntities[x][y][z] = state.getRight(); }
From source file:com.github.tddts.jet.config.spring.postprocessor.MessageAnnotationBeanPostProcessor.java
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { Pair<Class<?>, Object> typeObjectPair = SpringUtil.checkForDinamicProxy(bean); Class<?> type = typeObjectPair.getLeft(); Object target = typeObjectPair.getRight(); Method[] methods = type.getDeclaredMethods(); Field[] fields = type.getDeclaredFields(); for (Method method : methods) { if (checkMethod(method, type)) processMethod(target, method); }/*from ww w. j av a2s .c o m*/ for (Field field : fields) { if (checkField(field, type)) processField(target, field); } return bean; }
From source file:name.martingeisse.slave_services.babel.api.DownloadCakeTranslationFileApiHandler.java
@Override public void handle(final ApiRequestCycle requestCycle, final ApiRequestPathChain path) throws Exception { // parse request URI and load data if (path.isEmpty()) { throw new MissingRequestParameterException("domain"); }/* w ww .j a va 2 s . c om*/ ApiRequestPathChain subpath1 = path.getTail(); if (subpath1.isEmpty()) { throw new MissingRequestParameterException("language key"); } String domain = path.getHead(); String languageKey = subpath1.getHead(); // TODO what about missing ones? List<Pair<MessageFamily, MessageTranslation>> translationEntries = BabelDataUtil .loadDomainTranslations(domain, languageKey, false); // parse options if ("1".equals(requestCycle.getRequest().getParameter("download"))) { requestCycle.getResponse().addHeader("Content-Disposition", "attachment; filename=" + domain + ".po"); } // build the response requestCycle.getResponse().addHeader("Content-Type", "text/plain"); StringBuilder builder = new StringBuilder(); for (Pair<MessageFamily, MessageTranslation> translationEntry : translationEntries) { // TODO quote escaping builder.append("msgid \"").append(translationEntry.getLeft().getMessageKey()); builder.append("\"\nmsgstr \"").append(translationEntry.getRight().getText()); builder.append("\"\n\n"); requestCycle.getResponse().getWriter().print(builder); builder.setLength(0); } }
From source file:com.newlandframework.avatarmq.core.AckMessageCache.java
public void parallelDispatch(LinkedList<String> list) { List<Callable<Long>> tasks = new ArrayList<Callable<Long>>(); List<Future<Long>> futureList = new ArrayList<Future<Long>>(); int startPosition = 0; Pair<Integer, Integer> pair = calculateBlocks(list.size(), list.size()); int numberOfThreads = pair.getRight(); int blocks = pair.getLeft(); barrier = new CyclicBarrier(numberOfThreads); for (int i = 0; i < numberOfThreads; i++) { String[] task = new String[blocks]; System.arraycopy(list.toArray(), startPosition, task, 0, blocks); tasks.add(new AckMessageTask(barrier, task)); startPosition += blocks;//from w ww. j a va 2 s. c o m } ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads); try { futureList = executor.invokeAll(tasks); } catch (InterruptedException ex) { Logger.getLogger(AckMessageCache.class.getName()).log(Level.SEVERE, null, ex); } for (Future<Long> longFuture : futureList) { try { succTaskCount += longFuture.get(); } catch (InterruptedException ex) { Logger.getLogger(AckMessageCache.class.getName()).log(Level.SEVERE, null, ex); } catch (ExecutionException ex) { Logger.getLogger(AckMessageCache.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.qq.tars.service.PatchService.java
public String war2tgz(String packageWarPath, String serverName) throws Exception { String basePath = FilenameUtils.removeExtension(packageWarPath); String serverPath = basePath + "/" + serverName; String frameZipPath = new ClassPathResource("frame.zip").getFile().getCanonicalPath(); StringBuilder script = new StringBuilder(); script.append(String.format("rm -rf %s;", basePath)); script.append(String.format("mkdir -p %s;", serverPath)); script.append(String.format("unzip -q %s -d %s;", frameZipPath, serverPath)); script.append(String.format("unzip -q %s -d %s/apps/ROOT/;", packageWarPath, serverPath)); script.append(String.format("cd %s;tar -cvzf %s.tgz *;cd -;", basePath, basePath)); script.append(String.format("rm -rf %s;", basePath)); script.append(String.format("rm -rf %s;", packageWarPath)); Pair<Integer, Pair<String, String>> result = SystemUtils.exec(script.toString()); log.info("script={}, code={}, stdout={}, stderr={}", script, result.getLeft(), result.getRight().getLeft(), result.getRight().getRight()); return basePath + ".tgz"; }
From source file:blusunrize.immersiveengineering.client.render.IEBipedLayerRenderer.java
@Override public void doRenderLayer(EntityLivingBase living, float limbSwing, float prevLimbSwing, float partialTicks, float rotation, float yaw, float pitch, float scale) { // if(Lib.BAUBLES && living instanceof EntityPlayer) // {//from ww w .ja v a2s . c o m // ItemStack belt = BaublesHelper.getBauble((EntityPlayer)living,3); // if(belt!=null && belt.getItem().equals(IEContent.itemManeuverGear)) // { // GlStateManager.pushMatrix(); // ModelBiped model = IEContent.itemManeuverGear.getArmorModel((EntityPlayer)living, belt, 2, null); // ClientUtils.bindTexture(IEContent.itemManeuverGear.getArmorTexture(belt, (EntityPlayer)living, 2, null)); // model.render(living, limbSwing, prevLimbSwing, rotation, yaw, pitch, scale); // GlStateManager.popMatrix(); // } // } if (!living.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty() && ItemNBTHelper.hasKey(living.getItemStackFromSlot(EntityEquipmentSlot.HEAD), "IE:Earmuffs")) { ItemStack earmuffs = ItemNBTHelper.getItemStack(living.getItemStackFromSlot(EntityEquipmentSlot.HEAD), Lib.NBT_Earmuffs); if (!earmuffs.isEmpty()) { GlStateManager.pushMatrix(); ModelBiped model = IEContent.itemEarmuffs.getArmorModel(living, earmuffs, EntityEquipmentSlot.HEAD, null); ClientUtils.bindTexture(IEContent.itemEarmuffs.getArmorTexture(earmuffs, living, EntityEquipmentSlot.HEAD, "overlay")); model.render(living, limbSwing, prevLimbSwing, rotation, yaw, pitch, scale); int colour = ((IColouredItem) earmuffs.getItem()).getColourForIEItem(earmuffs, 0); GlStateManager.color((colour >> 16 & 255) / 255f, (colour >> 8 & 255) / 255f, (colour & 255) / 255f); ClientUtils.bindTexture( IEContent.itemEarmuffs.getArmorTexture(earmuffs, living, EntityEquipmentSlot.HEAD, null)); model.render(living, limbSwing, prevLimbSwing, rotation, yaw, pitch, scale); GlStateManager.popMatrix(); } } if (!living.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() && ItemNBTHelper.hasKey(living.getItemStackFromSlot(EntityEquipmentSlot.CHEST), "IE:Powerpack")) { ItemStack powerpack = ItemNBTHelper.getItemStack(living.getItemStackFromSlot(EntityEquipmentSlot.CHEST), Lib.NBT_Powerpack); addWornPowerpack(living, powerpack); } if (POWERPACK_PLAYERS.containsKey(living.getUniqueID())) { Pair<ItemStack, Integer> entry = POWERPACK_PLAYERS.get(living.getUniqueID()); renderPowerpack(entry.getLeft(), living, limbSwing, prevLimbSwing, partialTicks, rotation, yaw, pitch, scale); int time = entry.getValue() - 1; if (time <= 0) POWERPACK_PLAYERS.remove(living.getUniqueID()); else POWERPACK_PLAYERS.put(living.getUniqueID(), Pair.of(entry.getLeft(), time)); } }
From source file:com.twosigma.beaker.clojure.util.ClojureTableDeserializer.java
@Override @SuppressWarnings("unchecked") public Object deserialize(JsonNode n, ObjectMapper mapper) { org.apache.commons.lang3.tuple.Pair<String, Object> deserializeObject = TableDisplayDeSerializer .getDeserializeObject(parent, n, mapper); String subtype = deserializeObject.getLeft(); if (subtype != null && subtype.equals(TableDisplay.DICTIONARY_SUBTYPE)) { return PersistentArrayMap.create((Map) deserializeObject.getRight()); } else if (subtype != null && subtype.equals(TableDisplay.LIST_OF_MAPS_SUBTYPE)) { List<Map<String, Object>> rows = (List<Map<String, Object>>) deserializeObject.getRight(); List<Object> oo = new ArrayList<Object>(); for (Map<String, Object> row : rows) { oo.add(PersistentArrayMap.create(row)); }/*from w ww . j a v a 2 s.c o m*/ return PersistentVector.create(oo); } else if (subtype != null && subtype.equals(TableDisplay.MATRIX_SUBTYPE)) { List<List<?>> matrix = (List<List<?>>) deserializeObject.getRight(); return PersistentVector.create(matrix); } return deserializeObject.getRight(); }
From source file:net.community.chest.gitcloud.facade.AbstractEnvironmentInitializer.java
protected void extractConfigFiles(File confDir, Collection<Pair<String, Collection<String>>> filesList) { for (Pair<String, Collection<String>> p : filesList) { extractConfigFiles(confDir, p.getLeft(), p.getRight()); }/*from w ww. ja v a 2s. c om*/ }
From source file:com.hortonworks.registries.schemaregistry.state.DefaultCustomSchemaStateExecutor.java
@Override public void init(SchemaVersionLifecycleStateMachine.Builder builder, Byte successStateId, Byte retryStateId, Map<String, ?> props) { this.successState = builder.getStates().get(successStateId); this.retryState = builder.getStates().get(retryStateId); inReviewState = new InReviewState(successState); builder.register(inReviewState);/*from ww w. jav a 2 s .c om*/ for (Pair<SchemaVersionLifecycleStateTransition, SchemaVersionLifecycleStateAction> pair : inReviewState .getTransitionActions()) { builder.transition(pair.getLeft(), pair.getRight()); } }