Java Code Examples for java.util.Collections#unmodifiableList()

The following examples show how to use java.util.Collections#unmodifiableList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwitchRegion.java    From jadx with Apache License 2.0 5 votes vote down vote up
@Override
public List<IContainer> getSubBlocks() {
	List<IContainer> all = new ArrayList<>(cases.size() + 1);
	all.add(header);
	all.addAll(getCaseContainers());
	return Collections.unmodifiableList(all);
}
 
Example 2
Source File: ReferenceObjectBindingBoServiceImpl.java    From rice with Educational Community License v2.0 5 votes vote down vote up
public List<ReferenceObjectBinding> convertBosToImmutables(final Collection<ReferenceObjectBindingBo> referenceObjectBindingBos) {
    List<ReferenceObjectBinding> immutables = new LinkedList<ReferenceObjectBinding>();
    if (referenceObjectBindingBos != null) {
        ReferenceObjectBinding immutable = null;

        for (ReferenceObjectBindingBo bo : referenceObjectBindingBos ) {
            immutable = to(bo);
            immutables.add(immutable);
        }
    }

    return Collections.unmodifiableList(immutables);
}
 
Example 3
Source File: ApplicationProtocolConfig.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new instance.
 * @param protocol The application protocol functionality to use.
 * @param selectorBehavior How the peer selecting the protocol should behave.
 * @param selectedBehavior How the peer being notified of the selected protocol should behave.
 * @param supportedProtocols The order of iteration determines the preference of support for protocols.
 */
private ApplicationProtocolConfig(
        Protocol protocol, SelectorFailureBehavior selectorBehavior,
        SelectedListenerFailureBehavior selectedBehavior, List<String> supportedProtocols) {
    this.supportedProtocols = Collections.unmodifiableList(checkNotNull(supportedProtocols, "supportedProtocols"));
    this.protocol = checkNotNull(protocol, "protocol");
    this.selectorBehavior = checkNotNull(selectorBehavior, "selectorBehavior");
    this.selectedBehavior = checkNotNull(selectedBehavior, "selectedBehavior");

    if (protocol == Protocol.NONE) {
        throw new IllegalArgumentException("protocol (" + Protocol.NONE + ") must not be " + Protocol.NONE + '.');
    }
}
 
Example 4
Source File: CategoryBo.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Converts a list of mutable bos to it's immutable counterpart
 *
 * @param bos the list of mutable business objects
 * @return and immutable list containing the immutable objects
 */
public static List<CategoryDefinition> to(List<CategoryBo> bos) {
    if (bos == null) {
        return null;
    }

    List<CategoryDefinition> categories = new ArrayList<CategoryDefinition>();

    for (CategoryBo p : bos) {
        categories.add(CategoryDefinition.Builder.create(p).build());
    }

    return Collections.unmodifiableList(categories);
}
 
Example 5
Source File: CryptographicHashContent.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(final ProcessorInitializationContext context) {
    final Set<Relationship> _relationships = new HashSet<>();
    _relationships.add(REL_FAILURE);
    _relationships.add(REL_SUCCESS);
    relationships = Collections.unmodifiableSet(_relationships);

    final List<PropertyDescriptor> _properties = new ArrayList<>();
    _properties.add(FAIL_WHEN_EMPTY);
    _properties.add(HASH_ALGORITHM);
    properties = Collections.unmodifiableList(_properties);
}
 
Example 6
Source File: MatchedElement.java    From jolt with Apache License 2.0 5 votes vote down vote up
public MatchedElement( String key ) {
    super(key);

    List<String> keys = new ArrayList<>(1);
    keys.add( key ); // always add the full key to index 0

    this.subKeys = Collections.unmodifiableList( keys );
}
 
Example 7
Source File: NavigationPropertyImpl.java    From odata with Apache License 2.0 5 votes vote down vote up
private NavigationPropertyImpl(Builder builder) {
    super(builder);
    this.partnerName = builder.partnerName;
    this.containsTarget = builder.containsTarget;
    this.referentialConstraints = Collections.unmodifiableList(builder.constraintsBuilder);
    this.onDeleteActions = Collections.unmodifiableList(builder.onDeleteActionsBuilder);
}
 
Example 8
Source File: TreeBackedExecutableElement.java    From buck with Apache License 2.0 4 votes vote down vote up
@Override
public List<TreeBackedVariableElement> getParameters() {
  return Collections.unmodifiableList(parameters);
}
 
Example 9
Source File: MediaTypeNotSupportedStatusException.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Constructor for when the Content-Type is not supported.
 */
public MediaTypeNotSupportedStatusException(List<MediaType> supportedMediaTypes) {
	super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, "Unsupported media type", null);
	this.supportedMediaTypes = Collections.unmodifiableList(supportedMediaTypes);
}
 
Example 10
Source File: LanguageTag.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public List<String> getExtlangs() {
    if (extlangs.isEmpty()) {
        return Collections.emptyList();
    }
    return Collections.unmodifiableList(extlangs);
}
 
Example 11
Source File: StdMutableAdvice.java    From XACML with MIT License 4 votes vote down vote up
@Override
public Collection<AttributeAssignment> getAttributeAssignments() {
	return (this.attributeAssignments == EMPTY_ATTRIBUTE_ASSIGNMENTS ? this.attributeAssignments : Collections.unmodifiableList(this.attributeAssignments));
}
 
Example 12
Source File: AlertLog.java    From protect with MIT License 4 votes vote down vote up
public List<SimpleEntry<Integer, ErrorCondition>> getAlerts() {
	return Collections.unmodifiableList(alerts);
}
 
Example 13
Source File: TrackFragmentRandomAccessBox.java    From mp4parser with Apache License 2.0 4 votes vote down vote up
public List<Entry> getEntries() {
    return Collections.unmodifiableList(entries);
}
 
Example 14
Source File: AbstractMetaStore.java    From waggle-dance with Apache License 2.0 4 votes vote down vote up
public List<String> getWritableDatabaseWhiteList() {
  if (writableDatabaseWhitelist == null) {
    return Collections.emptyList();
  }
  return Collections.unmodifiableList(writableDatabaseWhitelist);
}
 
Example 15
Source File: CheckIndex.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "checkIndexProvider")
public void testCheckIndex(int index, int length, boolean withinBounds) {
    List<Integer> list = Collections.unmodifiableList(Arrays.asList(new Integer[] { index, length }));
    String expectedMessage = withinBounds
                             ? null
                             : Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
            apply("checkIndex", list).getMessage();

    BiConsumer<Class<? extends RuntimeException>, IntSupplier> checker = (ec, s) -> {
        try {
            int rIndex = s.getAsInt();
            if (!withinBounds)
                fail(String.format(
                        "Index %d is out of bounds of [0, %d), but was reported to be within bounds", index, length));
            assertEquals(rIndex, index);
        }
        catch (RuntimeException e) {
            assertTrue(ec.isInstance(e));
            if (withinBounds)
                fail(String.format(
                        "Index %d is within bounds of [0, %d), but was reported to be out of bounds", index, length));
            else
                assertEquals(e.getMessage(), expectedMessage);
        }
    };

    checker.accept(AssertingOutOfBoundsException.class,
                 () -> Preconditions.checkIndex(index, length,
                                                assertingOutOfBounds(expectedMessage, "checkIndex", index, length)));
    checker.accept(IndexOutOfBoundsException.class,
                 () -> Preconditions.checkIndex(index, length,
                                                assertingOutOfBoundsReturnNull("checkIndex", index, length)));
    checker.accept(IndexOutOfBoundsException.class,
                 () -> Preconditions.checkIndex(index, length, null));
    checker.accept(ArrayIndexOutOfBoundsException.class,
                 () -> Preconditions.checkIndex(index, length,
                                                Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
    checker.accept(StringIndexOutOfBoundsException.class,
                 () -> Preconditions.checkIndex(index, length,
                                                Preconditions.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
}
 
Example 16
Source File: JAXRSBindingFactory.java    From cxf with Apache License 2.0 4 votes vote down vote up
public JAXRSBindingFactory(Bus b) {
    super(b, Collections.unmodifiableList(Arrays.asList(
                                                        JAXRS_BINDING_ID)));
}
 
Example 17
Source File: GetDataAvailabilityResponse.java    From arctic-sea with Apache License 2.0 4 votes vote down vote up
/**
 * @return the {@code DataAvailabilities}.
 */
public List<DataAvailability> getDataAvailabilities() {
    return Collections.unmodifiableList(dataAvailabilities);
}
 
Example 18
Source File: FileAuthorizer.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void doOnConfigured(final AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
    try {
        final PropertyValue tenantsPath = configurationContext.getProperty(PROP_TENANTS_FILE);
        if (StringUtils.isBlank(tenantsPath.getValue())) {
            throw new AuthorizerCreationException("The users file must be specified.");
        }

        // get the tenants file and ensure it exists
        tenantsFile = new File(tenantsPath.getValue());
        if (!tenantsFile.exists()) {
            logger.info("Creating new users file at {}", new Object[] {tenantsFile.getAbsolutePath()});
            saveTenants(new Tenants());
        }

        final PropertyValue authorizationsPath = configurationContext.getProperty(PROP_AUTHORIZATIONS_FILE);
        if (StringUtils.isBlank(authorizationsPath.getValue())) {
            throw new AuthorizerCreationException("The authorizations file must be specified.");
        }

        // get the authorizations file and ensure it exists
        authorizationsFile = new File(authorizationsPath.getValue());
        if (!authorizationsFile.exists()) {
            logger.info("Creating new authorizations file at {}", new Object[] {authorizationsFile.getAbsolutePath()});
            saveAuthorizations(new Authorizations());
        }

        final File authorizationsFileDirectory = authorizationsFile.getAbsoluteFile().getParentFile();
        final File tenantsFileDirectory = tenantsFile.getAbsoluteFile().getParentFile();

        // the restore directory is optional and may be null
        final File restoreDirectory = properties.getRestoreDirectory();
        if (restoreDirectory != null) {
            // sanity check that restore directory is a directory, creating it if necessary
            FileUtils.ensureDirectoryExistAndCanAccess(restoreDirectory);

            // check that restore directory is not the same as the authorizations directory
            if (authorizationsFileDirectory.getAbsolutePath().equals(restoreDirectory.getAbsolutePath())) {
                throw new AuthorizerCreationException(String.format("Authorizations file directory '%s' is the same as restore directory '%s' ",
                        authorizationsFileDirectory.getAbsolutePath(), restoreDirectory.getAbsolutePath()));
            }

            // check that restore directory is not the same as the user's directory
            if (tenantsFileDirectory.getAbsolutePath().equals(restoreDirectory.getAbsolutePath())) {
                throw new AuthorizerCreationException(String.format("Users file directory '%s' is the same as restore directory '%s' ",
                        tenantsFileDirectory.getAbsolutePath(), restoreDirectory.getAbsolutePath()));
            }

            // the restore copy will have same file name, but reside in a different directory
            restoreAuthorizationsFile = new File(restoreDirectory, authorizationsFile.getName());
            restoreTenantsFile = new File(restoreDirectory, tenantsFile.getName());

            try {
                // sync the primary copy with the restore copy
                FileUtils.syncWithRestore(authorizationsFile, restoreAuthorizationsFile, logger);
                FileUtils.syncWithRestore(tenantsFile, restoreTenantsFile, logger);
            } catch (final IOException | IllegalStateException ioe) {
                throw new AuthorizerCreationException(ioe);
            }
        }

        // extract the identity mappings from nifi.properties if any are provided
        identityMappings = Collections.unmodifiableList(IdentityMappingUtil.getIdentityMappings(properties));

        // get the value of the initial admin identity
        final PropertyValue initialAdminIdentityProp = configurationContext.getProperty(PROP_INITIAL_ADMIN_IDENTITY);
        initialAdminIdentity = initialAdminIdentityProp == null ? null : IdentityMappingUtil.mapIdentity(initialAdminIdentityProp.getValue(), identityMappings);

        // get the value of the legacy authorized users file
        final PropertyValue legacyAuthorizedUsersProp = configurationContext.getProperty(PROP_LEGACY_AUTHORIZED_USERS_FILE);
        legacyAuthorizedUsersFile = legacyAuthorizedUsersProp == null ? null : legacyAuthorizedUsersProp.getValue();

        // extract any node identities
        nodeIdentities = new HashSet<>();
        for (Map.Entry<String,String> entry : configurationContext.getProperties().entrySet()) {
            Matcher matcher = NODE_IDENTITY_PATTERN.matcher(entry.getKey());
            if (matcher.matches() && !StringUtils.isBlank(entry.getValue())) {
                nodeIdentities.add(IdentityMappingUtil.mapIdentity(entry.getValue(), identityMappings));
            }
        }

        // load the authorizations
        load();

        // if we've copied the authorizations file to a restore directory synchronize it
        if (restoreAuthorizationsFile != null) {
            FileUtils.copyFile(authorizationsFile, restoreAuthorizationsFile, false, false, logger);
        }

        // if we've copied the authorizations file to a restore directory synchronize it
        if (restoreTenantsFile != null) {
            FileUtils.copyFile(tenantsFile, restoreTenantsFile, false, false, logger);
        }

        logger.info(String.format("Authorizations file loaded at %s", new Date().toString()));

    } catch (IOException | AuthorizerCreationException | JAXBException | IllegalStateException | SAXException e) {
        throw new AuthorizerCreationException(e);
    }
}
 
Example 19
Source File: Message.java    From Jumble with GNU General Public License v3.0 4 votes vote down vote up
@Override
public List<Channel> getTargetTrees() {
    return Collections.unmodifiableList(mTrees);
}
 
Example 20
Source File: QueryAvailableScriptFiles.java    From openAGV with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param fileNames The list of available script files.
 */
public QueryAvailableScriptFiles(List<String> fileNames) {
  this.fileNames = Collections.unmodifiableList(
      Objects.requireNonNull(fileNames, "fileNames is null"));
}