Java Code Examples for com.google.common.collect.ImmutableSet.copyOf()

The following are Jave code examples for showing how to use copyOf() of the com.google.common.collect.ImmutableSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: PropertyEnum.java   View Source Code Vote up 6 votes
protected PropertyEnum(String name, Class<T> valueClass, Collection<T> allowedValues)
{
    super(name, valueClass);
    this.allowedValues = ImmutableSet.copyOf(allowedValues);

    for (T t : allowedValues)
    {
        String s = ((IStringSerializable)t).getName();

        if (this.nameToValue.containsKey(s))
        {
            throw new IllegalArgumentException("Multiple values have the same name \'" + s + "\'");
        }

        this.nameToValue.put(s, t);
    }
}
 
Example 2
Project: Equella   File: CShuffleList.java   View Source Code Vote up 6 votes
@Override
public void validate()
{
	if( checkDuplication || forceUnique )
	{
		final Set<String> values = new HashSet<String>();
		for( NameValue nv : namesValues )
		{
			// nv.value is URL encoded, but the name is ok to use
			values.add(nv.getName());
		}
		final ImmutableCollection<String> valuesReadonly = ImmutableSet.copyOf(values);

		// We need to inform the wizard to check for uniqueness every time,
		// no matter what
		final boolean isUnique = getRepository().checkDataUniqueness(getFirstTarget().getXoqlPath(),
			valuesReadonly, !forceUnique);

		setInvalid(forceUnique && !isUnique && !isInvalid(),
			new KeyLabel("wizard.controls.editbox.uniqueerror")); //$NON-NLS-1$
	}
}
 
Example 3
Project: Backmemed   File: PropertyInteger.java   View Source Code Vote up 6 votes
protected PropertyInteger(String name, int min, int max)
{
    super(name, Integer.class);

    if (min < 0)
    {
        throw new IllegalArgumentException("Min value of " + name + " must be 0 or greater");
    }
    else if (max <= min)
    {
        throw new IllegalArgumentException("Max value of " + name + " must be greater than min (" + min + ")");
    }
    else
    {
        Set<Integer> set = Sets.<Integer>newHashSet();

        for (int i = min; i <= max; ++i)
        {
            set.add(Integer.valueOf(i));
        }

        this.allowedValues = ImmutableSet.copyOf(set);
    }
}
 
Example 4
Project: athena   File: OpticalPathIntent.java   View Source Code Vote up 6 votes
private OpticalPathIntent(ApplicationId appId,
                          Key key,
                          ConnectPoint src,
                          ConnectPoint dst,
                          Path path,
                          OchSignal lambda,
                          OchSignalType signalType,
                          boolean isBidirectional,
                          int priority) {
    super(appId, key, ImmutableSet.copyOf(path.links()), priority);
    this.src = checkNotNull(src);
    this.dst = checkNotNull(dst);
    this.path = checkNotNull(path);
    this.lambda = checkNotNull(lambda);
    this.signalType = checkNotNull(signalType);
    this.isBidirectional = isBidirectional;
}
 
Example 5
Project: Reer   File: DefaultVariantsMetaData.java   View Source Code Vote up 5 votes
private DefaultVariantsMetaData(Map<String, Object> variantCoordinates, Map<String, ModelType<?>> variantAxisTypes) {
    this.variantCoordinates = variantCoordinates;
    this.allVariantAxes = variantCoordinates.keySet();
    this.nonNullVariantAxes = ImmutableSet.copyOf(Maps.filterEntries(variantCoordinates, new Predicate<Map.Entry<String, Object>>() {
        @Override
        public boolean apply(Map.Entry<String, Object> input) {
            return input.getValue()!=null;
        }
    }).keySet());
    this.variantAxisTypes = variantAxisTypes;
}
 
Example 6
Project: dremio-oss   File: CopyWithCluster.java   View Source Code Vote up 5 votes
@Override
public RelNode visit(LogicalFilter filter) {
  final RelNode input = filter.getInput().accept(this);
  return new LogicalFilter(
    cluster,
    copyOf(filter.getTraitSet()),
    input,
    copyOf(filter.getCondition()),
    ImmutableSet.copyOf(filter.getVariablesSet())
  );
}
 
Example 7
Project: centraldogma   File: CreateProjectRequest.java   View Source Code Vote up 5 votes
@JsonCreator
public CreateProjectRequest(@JsonProperty("name") String name,
                            @JsonProperty("owners") @Nullable Set<String> owners,
                            @JsonProperty("members") @Nullable Set<String> members) {
    this.name = validateProjectName(name, "name");
    this.owners = owners != null ? ImmutableSet.copyOf(owners) : ImmutableSet.of();
    this.members = members != null ? ImmutableSet.copyOf(members) : ImmutableSet.of();
}
 
Example 8
Project: verify-hub   File: LevelsOfAssuranceConfigValidator.java   View Source Code Vote up 5 votes
private List<IdentityProviderConfigEntityData> unsupportedIdpsForATransaction(Set<IdentityProviderConfigEntityData> identityProviderConfigEntityData, TransactionConfigEntityData transactionConfigEntityData) {
    Set<LevelOfAssurance> transactionLOAs = ImmutableSet.copyOf(transactionConfigEntityData.getLevelsOfAssurance());
    return identityProviderConfigEntityData.stream()
            .filter(idp -> isIdpForTransaction(transactionConfigEntityData, idp))
            .filter(idp -> idpCannotFulfillLoaRequirements(transactionLOAs, idp))
            .collect(Collectors.toList());
}
 
Example 9
Project: kubernetes-HDFS   File: PodCIDRToNodeMapping.java   View Source Code Vote up 5 votes
private static PodCIDRLookup buildLookup(Set<String> nodeNames,
    Map<String, Map<String, String>> netmaskToNetworkToNode) {
  ImmutableList.Builder<ImmutablePair<Netmask, ImmutableMap<NetworkAddress, String>>> builder =
      ImmutableList.builder();
  for (Map.Entry<String, Map<String, String>> entry : netmaskToNetworkToNode.entrySet()) {
    Netmask netmask = new Netmask(entry.getKey());
    ImmutableMap.Builder<NetworkAddress, String> networkToNodeBuilder = ImmutableMap.builder();
    for (Map.Entry<String, String> networkToNode : entry.getValue().entrySet()) {
      networkToNodeBuilder.put(new NetworkAddress(networkToNode.getKey()),
          networkToNode.getValue());
    }
    builder.add(ImmutablePair.of(netmask, networkToNodeBuilder.build()));
  }
  return new PodCIDRLookup(builder.build(), ImmutableSet.copyOf(nodeNames));
}
 
Example 10
Project: athena   File: PceManagerTest.java   View Source Code Vote up 5 votes
@Override
public Collection<Tunnel> queryTunnel(Tunnel.Type type) {
    Collection<Tunnel> result = new HashSet<Tunnel>();

    for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
        result.add(tunnelIdAsKeyStore.get(tunnelId));
    }

    return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
}
 
Example 11
Project: iron   File: EntityStore.java   View Source Code Vote up 5 votes
public EntityStore(EntityDefinition<E> entityDefinition, Map<RelationDefinition, RelationStore> relationStores) {
    m_entityDefinition = entityDefinition;
    m_entityClass = entityDefinition.getEntityClass();
    m_entityName = entityDefinition.getEntityName();

    IdDefinition idDefinition = entityDefinition.getIdDefinition();
    m_idPropertyName = idDefinition != null ? idDefinition.getIdName() : null;

    m_attributes = ImmutableSet
            .copyOf(entityDefinition.getAttributes().values().stream().map(AttributeDefinition::getAttributeName).collect(Collectors.toList()));

    ImmutableMap.Builder<String, Map<Object, Long>> uniquesIndex = ImmutableMap.builder();
    entityDefinition.getUniqueConstraints().forEach(uniqueAttribute -> uniquesIndex.put(uniqueAttribute, new HashMap<>()));
    m_uniquesIndex = uniquesIndex.build();

    ImmutableSet.Builder<String> nonNullAttributes = ImmutableSet.builder();
    entityDefinition.getAttributes().values().stream() //
            .filter(attributeDefinition -> !attributeDefinition.isNullable()) //
            .forEach(attributeDefinition -> nonNullAttributes.add(attributeDefinition.getAttributeName()));
    m_nonNullAttributes = nonNullAttributes.build();

    ImmutableMap.Builder<String, RelationStore> relationStoresBuilder = ImmutableMap.builder();
    entityDefinition.getRelations().values().forEach(relationDefinition -> {
        RelationStore relationStore = relationStores.get(relationDefinition);
        relationStoresBuilder.put(relationDefinition.getRelationName(), relationStore);
    });
    m_relationStores = relationStoresBuilder.build();
}
 
Example 12
Project: tac-kbp-eal   File: SystemOutputEquivalenceClasses.java   View Source Code Vote up 4 votes
@Override
public Set<Response> answers(final Answerable answerable) {
  return ImmutableSet.copyOf(equivalenceClasses.get(answerable));
}
 
Example 13
Project: ArchUnit   File: JavaConstructor.java   View Source Code Vote up 4 votes
void registerCallsToConstructor(Collection<JavaConstructorCall> calls) {
    this.callsToSelf = ImmutableSet.copyOf(calls);
}
 
Example 14
Project: tac-kbp-eal   File: TypeAndRoleValidator.java   View Source Code Vote up 4 votes
public ImmutableSet<Symbol> validRolesFor(Symbol type) {
  checkNotNull(type);
  return ImmutableSet.copyOf(concat(validRoles.get(type), alwaysValidRoles));
}
 
Example 15
Project: athena   File: AtomixLeaderElector.java   View Source Code Vote up 4 votes
@Override
public Collection<Consumer<Status>> statusChangeListeners() {
    return ImmutableSet.copyOf(statusChangeListeners);
}
 
Example 16
Project: QuarSK   File: Registration.java   View Source Code Vote up 4 votes
public static Set<QuarskSyntaxInfo> getEffects() {
	return ImmutableSet.copyOf(effects);
}
 
Example 17
Project: ProjectAres   File: ProximityGoal.java   View Source Code Vote up 4 votes
public void resetProximity() {
    for(Competitor team : ImmutableSet.copyOf(proximity.keySet())) {
        resetProximity(team);
    }
}
 
Example 18
Project: cfn-core   File: ConfigurableImmutabilityStrategy.java   View Source Code Vote up 4 votes
public ConfigurableImmutabilityStrategy(List<String> semiMutablePropertyPaths, List<String> mutablePropertyPaths) {
    this.semiMutablePropertyPaths = ImmutableSet.copyOf(semiMutablePropertyPaths);
    this.mutablePropertyPaths = ImmutableSet.copyOf(mutablePropertyPaths);
}
 
Example 19
Project: tac-kbp-eal   File: EREToKBPEventOntologyMapper.java   View Source Code Vote up 4 votes
@Override
public ImmutableSet<Symbol> eventSubtypes() {
  return ImmutableSet.copyOf(eventSubtypes.values());
}
 
Example 20
Project: ArchUnit   File: Architectures.java   View Source Code Vote up 4 votes
@PublicAPI(usage = ACCESS)
public LayeredArchitecture definedBy(String... packageIdentifiers) {
    this.packageIdentifiers = ImmutableSet.copyOf(packageIdentifiers);
    return LayeredArchitecture.this.addLayerDefinition(this);
}