Example usage for java.util Collections unmodifiableList

List of usage examples for java.util Collections unmodifiableList

Introduction

In this page you can find the example usage for java.util Collections unmodifiableList.

Prototype

public static <T> List<T> unmodifiableList(List<? extends T> list) 

Source Link

Document

Returns an unmodifiable view of the specified list.

Usage

From source file:com.ok2c.lightmtp.protocol.BasicDeliveryResult.java

public BasicDeliveryResult(final SMTPReply reply, final List<RcptResult> rcptFailures) {
    super();/*from w  w  w  . j  a  va  2s  . com*/
    Args.notNull(reply, "SMTP reply");
    this.reply = reply;
    ArrayList<RcptResult> list = new ArrayList<RcptResult>();
    if (rcptFailures != null) {
        list.addAll(rcptFailures);
    }
    this.failures = Collections.unmodifiableList(list);
}

From source file:Main.java

public static <E> Collection<List<E>> selectExactly(List<E> original, int nb) {
    if (nb < 0) {
        throw new IllegalArgumentException();
    }/*  ww w .j  a va 2  s  .c  o  m*/
    if (nb == 0) {
        return Collections.emptyList();
    }
    if (nb == 1) {
        final List<List<E>> result = new ArrayList<List<E>>();
        for (E element : original) {
            result.add(Collections.singletonList(element));
        }
        return result;

    }
    if (nb > original.size()) {
        return Collections.emptyList();
    }
    if (nb == original.size()) {
        return Collections.singletonList(original);
    }
    final List<List<E>> result = new ArrayList<List<E>>();

    for (List<E> subList : selectExactly(original.subList(1, original.size()), nb - 1)) {
        final List<E> newList = new ArrayList<E>();
        newList.add(original.get(0));
        newList.addAll(subList);
        result.add(Collections.unmodifiableList(newList));
    }
    result.addAll(selectExactly(original.subList(1, original.size()), nb));

    return Collections.unmodifiableList(result);
}

From source file:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinderListDeveloper.java

public IndexingUriFinderListDeveloper(Collection<? extends IndexingUriFinder> finders) {
    List<FinderTiming> list = new ArrayList<>();
    for (IndexingUriFinder finder : finders) {
        list.add(new FinderTiming(finder));
    }//from w w  w .  jav  a 2  s .c o  m
    this.timings = Collections.unmodifiableList(list);
}

From source file:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.SearchIndexExcluderListDeveloper.java

public SearchIndexExcluderListDeveloper(Collection<? extends SearchIndexExcluder> excluders) {

    List<ExcluderTiming> list = new ArrayList<>();
    for (SearchIndexExcluder excluder : excluders) {
        list.add(new ExcluderTiming(excluder));
    }/* w  w  w.  j a  v  a  2 s.c o m*/
    this.timings = Collections.unmodifiableList(list);
}

From source file:com.ok2c.lightmtp.SMTPReply.java

public SMTPReply(final int code, final SMTPCode enhancedCode, final List<String> lines) {
    super();// w  w  w.j  av  a2s.  c o  m
    if (code <= 0) {
        throw new IllegalArgumentException("Code may not be nagtive or zero");
    }
    this.code = code;
    this.enhancedCode = enhancedCode;
    if (lines == null || lines.isEmpty()) {
        this.lines = Collections.emptyList();
    } else {
        this.lines = Collections.unmodifiableList(new ArrayList<String>(lines));
    }
}

From source file:com.palantir.tslint.services.Request.java

public Request(String method, Object... arguments) {
    checkNotNull(method);//from   ww w  . j ava2 s .co m
    checkNotNull(arguments);

    this.method = method;
    this.arguments = Collections.unmodifiableList(Arrays.asList(arguments));
}

From source file:org.cloudfoundry.identity.uaa.test.TestApplicationEventHandler.java

public List<T> getEvents() {
    return Collections.unmodifiableList(events);
}

From source file:io.netty.handler.codec.mqtt.MqttSubAckPayload.java

public MqttSubAckPayload(MqttGrantedQoS... grantedQoSLevels) {
    if (grantedQoSLevels == null) {
        throw new IllegalArgumentException("Empty grantedQoSLevels");
    }/*from   w ww .  jav a2 s .com*/
    List<MqttGrantedQoS> list = new ArrayList<>(grantedQoSLevels.length);
    Collections.addAll(list, grantedQoSLevels);
    this.grantedQoSLevels = Collections.unmodifiableList(list);
}

From source file:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifierListDeveloper.java

public DocumentModifierListDeveloper(Collection<? extends DocumentModifier> modifiers) {
    List<ModifierTiming> list = new ArrayList<>();
    for (DocumentModifier modifier : modifiers) {
        list.add(new ModifierTiming(modifier));
    }/*www . j  a  va2 s  . c  o  m*/
    this.timings = Collections.unmodifiableList(list);
}

From source file:net.community.chest.gitcloud.facade.frontend.git.GitControllerTest.java

@Test
public void testExtractRepositoryNameFromValidPaths() {
    final String expected = "testExtractRepositoryName" + Constants.DOT_GIT_EXT;
    List<String> prefixes = Collections.unmodifiableList(Arrays.asList("", "/", "/l/y/o/r/"));
    List<String> suffixes = Collections.unmodifiableList(Arrays.asList("", "/", "/r/o/y/l"));
    for (String prfx : prefixes) {
        for (String sfx : suffixes) {
            String uriPath = prfx + expected + sfx;
            String actual = GitController.extractRepositoryName(uriPath);
            assertEquals("Mismatched name for path=" + uriPath, expected, actual);
        }/*from   w  w  w  .  jav  a  2  s. c  o m*/
    }
}