All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.samples.java.ex.MUC_Sample Maven / Gradle / Ivy

Go to download

An auxiliary findbugs.sourceforge.net plugin for java bug detectors that fall outside the narrow scope of detectors to be packaged with the product itself.

There is a newer version: 7.6.8
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy