List of usage examples for org.apache.commons.lang3.tuple ImmutableTriple of
public static <L, M, R> ImmutableTriple<L, M, R> of(final L left, final M middle, final R right)
Obtains an immutable triple of from three objects inferring the generic types.
This factory allows the triple to be created using inference to obtain the generic types.
From source file:com.ethylamine.fsynthesis.util.position.ChunkBlockCoord.java
@SuppressWarnings("NumericCastThatLosesPrecision") private ChunkBlockCoord(int x, int y, int z) { Preconditions.checkArgument(x >= 0 && x < 16); Preconditions.checkArgument(z >= 0 && z < 16); data = ImmutableTriple.of((byte) x, y, (byte) z); }
From source file:com.ethylamine.fsynthesis.util.position.WorldBlockCoord.java
private WorldBlockCoord(int x, int y, int z) { data = ImmutableTriple.of(x, y, z); }
From source file:edu.umd.umiacs.clip.tools.scor.PSQW2VBM25Scorer.java
private float scoreWeighted(List<Map<String, Float>> wightedQuery, Map<String, Integer> docTerms) { int length = docTerms.values().parallelStream().mapToInt(f -> f).sum(); return (float) wightedQuery.parallelStream().mapToDouble(weightedTerm -> { List<Triple<Float, Float, Float>> list = weightedTerm.entrySet().stream() .filter(entry -> docTerms.containsKey(entry.getKey())) .map(entry -> ImmutableTriple.of(docTerms.get(entry.getKey()).floatValue(), (float) df(entry.getKey()), entry.getValue())) .collect(toList());//from ww w . ja va2 s. c o m float averageTF = (float) list.parallelStream() .mapToDouble(triple -> triple.getLeft() * triple.getRight()).sum(); float averageDF = (float) list.parallelStream() .mapToDouble(triple -> triple.getMiddle() * triple.getRight()).sum(); return bm25(averageTF, averageDF, length); }).sum(); }
From source file:cc.kave.commons.pointsto.evaluation.events.MRREvaluation.java
private void evaluateType(String validationAnalysisName, ICoReTypeName type, Map<ICoReTypeName, Map<ICompletionEvent, List<Usage>>> queries) throws IOException { log("\t%s:\n", CoReNames.vm2srcQualifiedType(type)); for (UsageStore store : usageStores) { ICallsRecommender<Query> recommender = null; {/*from w ww . java2s . c o m*/ List<Usage> usages = store.load(type, usageFilter); store.flush(); int numPrunedUsages = pruning.prune(MAX_USAGES, usages); if (numPrunedUsages > 0) { usages = new ArrayList<>(usages); prunedUsages.add(ImmutableTriple.of(store.getName(), type, numPrunedUsages)); } if (!usages.isEmpty()) { recommender = trainRecommender(usages); } } double score = 0; if (recommender == null) { log("\t\t%s: no usages\n", store.getName()); } else { score = calcMRR(recommender, queries.get(type)); log("\t\t%s: %.3f\n", store.getName(), score); } results.put(ImmutableTriple.of(type, store.getName(), validationAnalysisName), score); } }
From source file:io.lavagna.service.NotificationService.java
private ImmutableTriple<String, String, String> composeEmailForUser(EventsContext context) throws MustacheException, IOException { List<Map<String, Object>> cardsModel = new ArrayList<>(); StringBuilder subject = new StringBuilder(); for (Entry<Integer, List<Event>> kv : context.events.entrySet()) { Map<String, Object> cardModel = new HashMap<>(); CardFull cf = context.cards.get(kv.getKey()); StringBuilder cardName = new StringBuilder(cf.getBoardShortName()).append("-").append(cf.getSequence()) .append(" ").append(cf.getName()); cardModel.put("cardFull", cf); cardModel.put("cardName", cardName.toString()); cardModel.put("cardEvents", composeCardSection(kv.getValue(), context)); subject.append(cf.getBoardShortName()).append("-").append(cf.getSequence()).append(", "); cardsModel.add(cardModel);// w ww .j a v a 2s.c o m } Map<String, Object> tmplModel = new HashMap<>(); String baseApplicationUrl = StringUtils .appendIfMissing(configurationRepository.getValue(Key.BASE_APPLICATION_URL), "/"); tmplModel.put("cards", cardsModel); tmplModel.put("baseApplicationUrl", baseApplicationUrl); tmplModel.put("htmlEscape", new Mustache.Lambda() { @Override public void execute(Fragment frag, Writer out) throws IOException { out.write(Escapers.HTML.escape(frag.execute())); } }); String text = emailTextTemplate.execute(tmplModel); String html = emailHtmlTemplate.execute(tmplModel); return ImmutableTriple.of(subject.substring(0, subject.length() - ", ".length()), text, html); }
From source file:org.apache.syncope.core.logic.ResourceLogic.java
private Triple<ExternalResource, AnyType, Provision> connObjectInit(final String resourceKey, final String anyTypeKey) { ExternalResource resource = resourceDAO.authFind(resourceKey); if (resource == null) { throw new NotFoundException("Resource '" + resourceKey + "'"); }//from www . ja va2 s . c o m AnyType anyType = anyTypeDAO.find(anyTypeKey); if (anyType == null) { throw new NotFoundException("AnyType '" + anyTypeKey + "'"); } Optional<? extends Provision> provision = resource.getProvision(anyType); if (!provision.isPresent()) { throw new NotFoundException( "Provision on resource '" + resourceKey + "' for type '" + anyTypeKey + "'"); } return ImmutableTriple.of(resource, anyType, provision.get()); }
From source file:rapture.plugin.install.PluginSandboxItem.java
/** * Split the path of a filename into the extensionless path (for URI construction) and the URI scheme (based on the file extension) * /*from w w w. j av a2 s. c om*/ * @param path * The relative path within the contents directory * @return a triple of the path (left), the attribute(middle), and the URI scheme (right) */ public static Triple<String, String, Scheme> extractScheme(String path) { int chop = path.lastIndexOf('.'); if (chop < 0) return null; String schemeName = path.substring(chop); String attr = null; Scheme scheme = ext2scheme.get(schemeName); if (scheme == null) { scheme = raw2scheme.get(schemeName); if (scheme == null) { scheme = BLOB; // Oooerr - unmatched extensions will be blobs (THIS IS GOOD, BELIEVE ME) } else { path = path.substring(0, chop); } switch (scheme) { case BLOB: attr = getResolver().getMimeTypeFromPath(path); break; case SCRIPT: attr = schemeName.equals(".jjs") ? "jjs" : "raw"; break; default: throw new Error("Severe: Unhandled scheme in raw2scheme map"); // can only happen if a bad checkin is made } } else { path = path.substring(0, chop); } return ImmutableTriple.of(path, attr, scheme); }