
src.samples.java.ex.MUC_Sample Maven / Gradle / Ivy
package ex;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class MUC_Sample {
public void testMUC() {
List l = getImmutableList();
l.add("Uhoh");
}
public void testPossiblyMUC() {
Set s = getPossiblyImmutableSet(Math.random() > 0.5);
s.add("Yowsers");
}
public void testMUCChained() {
List l = getImmutableListChained();
l.add("Uhoh");
}
public List getImmutableList() {
return Arrays.asList("foo");
}
public Set getPossiblyImmutableSet(boolean b) {
if (b)
return Collections.unmodifiableSet(new HashSet());
return new HashSet();
}
public List getImmutableListChained() {
return getImmutableList();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy