List of usage examples for com.google.common.collect Sets newLinkedHashSet
public static <E> LinkedHashSet<E> newLinkedHashSet(Iterable<? extends E> elements)
From source file:biz.ganttproject.impex.msproject2.CustomPropertyMapping.java
private static <T extends Enum<T>, S extends FieldType> Map<CustomPropertyDefinition, FieldType> buildMapping( final CustomPropertyManager customPropertyManager, final SortedSet<S> mpxjFields, final Class<T> enumClass) throws MPXJException { final Map<CustomPropertyDefinition, FieldType> result = new HashMap<>(); class Filter { private LinkedHashSet<CustomPropertyDefinition> allDefs = Sets .newLinkedHashSet(customPropertyManager.getDefinitions()); private void run(final Function<CustomPropertyDefinition, String> fxnFieldName) { run0(new Function<CustomPropertyDefinition, S>() { @Override//from w w w.j a v a 2 s.c om public S apply(@Nullable CustomPropertyDefinition def) { String msProjectType = fxnFieldName.apply(def); return (msProjectType == null) ? null : (S) Enum.valueOf(enumClass, msProjectType); } }); } private void run0(Function<CustomPropertyDefinition, S> fxnTaskField) { for (Iterator<CustomPropertyDefinition> it = allDefs.iterator(); it.hasNext();) { CustomPropertyDefinition def = it.next(); try { FieldType tf = fxnTaskField.apply(def); if (tf != null) { result.put(def, tf); mpxjFields.remove(tf); it.remove(); } } catch (IllegalArgumentException e) { // That's somewhat okay. We have not found such value in the enum, but it might come from the future // versions of MPXJ, so it is not the reason to fail } } } } Filter f = new Filter(); // First pass: search for saved MSPROJECT_TYPE attributes. f.run(new Function<CustomPropertyDefinition, String>() { @Override public String apply(@Nullable CustomPropertyDefinition def) { return def.getAttributes().get(MSPROJECT_TYPE); } }); // Second pass: find properties with predefined names f.run(new Function<CustomPropertyDefinition, String>() { @Override public String apply(@Nullable CustomPropertyDefinition def) { return def.getName().toUpperCase(); } }); // Third pass: provide appropriate types for the remaining properties f.run0(new Function<CustomPropertyDefinition, S>() { @Override public S apply(@Nullable CustomPropertyDefinition def) { String name; switch (def.getPropertyClass()) { case BOOLEAN: name = "FLAG"; break; case INTEGER: case DOUBLE: name = "NUMBER"; break; case TEXT: name = "TEXT"; break; case DATE: name = "DATE"; break; default: assert false : "Should not be here"; name = "TEXT"; } for (int i = 1; i <= 30; i++) { S tf1 = (S) Enum.valueOf(enumClass, name + String.valueOf(i)); if (mpxjFields.contains(tf1)) { return tf1; } } return null; } }); if (!f.allDefs.isEmpty()) { List<String> remainingColumns = Lists .newArrayList(Iterables.transform(f.allDefs, new Function<CustomPropertyDefinition, String>() { @Override public String apply(@Nullable CustomPropertyDefinition def) { return def.getName(); } })); throw new MPXJException( String.format("Some of the custom columns failed to export: %s", remainingColumns)); } return result; }
From source file:uk.ac.ebi.atlas.model.differential.DifferentialExperiment.java
public Set<Contrast> getContrasts() { return Sets.newLinkedHashSet(contrastsById.values()); }
From source file:net.hillsdon.reviki.web.urls.impl.ApplicationUrlsImpl.java
public Set<WikiUrls> getAvailableWikiUrls() { return Sets.newLinkedHashSet(Iterables.transform(_deploymentConfiguration.getWikis(), new Function<WikiConfiguration, WikiUrls>() { public WikiUrls apply(final WikiConfiguration wiki) { return get(wiki.getWikiName()); }//from www. j a v a2 s . co m })); }
From source file:au.id.wolfe.fxassetman.server.dao.jpa.GenericDaoImpl.java
@Override @SuppressWarnings("unchecked") public PaginatedResult<T> findAll(int start, int limit) { Set<T> resultSet = Sets.newLinkedHashSet(entityManager.createQuery("SELECT e FROM " + type.getName() + " e") .setFirstResult(start).setMaxResults(limit).getResultList()); PaginatedResult<T> paginatedResult = new PaginatedResult<T>(type); Long totalCount = (Long) entityManager.createQuery("select count(o) from " + type.getName() + " as o") .getSingleResult();/*from w ww. jav a2 s .c om*/ paginatedResult.setTotalRecords(totalCount); paginatedResult.setResultSet(resultSet); return paginatedResult; }
From source file:org.jclouds.tmrk.enterprisecloud.domain.resource.memory.MemoryUsageDetails.java
private MemoryUsageDetails(Set<ComputePoolMemoryUsageDetailSummaryEntry> entries) { this.entries = Sets.newLinkedHashSet(entries); }
From source file:org.jclouds.tmrk.enterprisecloud.domain.network.NetworkAdapterSettings.java
private NetworkAdapterSettings(Set<NetworkAdapterSetting> adapters) { this.adapters = Sets.newLinkedHashSet(adapters); }
From source file:org.jclouds.tmrk.enterprisecloud.domain.template.TemplateCategories.java
private TemplateCategories(Set<TemplateCategory> categories) { this.categories = Sets.newLinkedHashSet(categories); }
From source file:org.jclouds.trmk.vcloud_0_8.functions.OrgsForLocations.java
/** * Zones are assignable, but we want regions. so we look for zones, whose * parent is region. then, we use a set to extract the unique set. *///from ww w . ja v a 2s .co m @Override public Iterable<? extends Org> apply(Iterable<? extends Location> from) { return transformParallel(Sets.newLinkedHashSet(transform(filter(from, new Predicate<Location>() { public boolean apply(Location input) { return input.getScope() == LocationScope.ZONE; } }), new Function<Location, URI>() { public URI apply(Location from) { return URI.create(from.getParent().getId()); } })), new Function<URI, ListenableFuture<? extends Org>>() { public ListenableFuture<? extends Org> apply(URI from) { return aclient.getOrg(from); } }, userExecutor, null, logger, "organizations for uris"); }
From source file:org.gradle.nativeplatform.test.internal.DefaultNativeTestSuiteBinarySpec.java
@Override public Set<LanguageSourceSet> getAllSources() { Set<LanguageSourceSet> sources = Sets.newLinkedHashSet(super.getAllSources()); sources.addAll(testedBinary.getAllSources()); return sources; }
From source file:org.jclouds.s3.blobstore.functions.ResourceToBucketList.java
public ListBucketResponse apply(PageSet<? extends StorageMetadata> list) { Iterable<ObjectMetadata> contents = Iterables .transform(Iterables.filter(list, new Predicate<StorageMetadata>() { public boolean apply(StorageMetadata input) { return input.getType() == StorageType.BLOB; }/*from ww w.ja v a 2 s .co m*/ }), new Function<StorageMetadata, ObjectMetadata>() { public MutableObjectMetadata apply(StorageMetadata from) { return blob2ObjectMd.apply((BlobMetadata) from); } }); Set<String> commonPrefixes = Sets .newLinkedHashSet(Iterables.transform(Iterables.filter(list, new Predicate<StorageMetadata>() { public boolean apply(StorageMetadata input) { return input.getType() == StorageType.RELATIVE_PATH; } }), new Function<StorageMetadata, String>() { public String apply(StorageMetadata from) { return from.getName(); } })); return new ListBucketResponseImpl(null, contents, null, null, list.getNextMarker(), 0, "/", list.getNextMarker() != null, commonPrefixes); }