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

src.samples.java.ex.MUI_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.

The newest version!
package ex;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MUI_Sample {

    Map fieldMap = new HashMap<>();

    public String testGetAfterContainsKeyLocal() {
        Map localMap = new HashMap<>();

        if (localMap.containsKey("Foo")) {
            String v = localMap.get("Foo");
            return v + "Bar";
        } else {
            return "Bar";
        }
    }

    public String testGetAfterContainsKeyWithReg() {
        Map localMap = new HashMap<>();
        Date d = new Date();

        if (localMap.containsKey(d)) {
            String v = localMap.get(d);
            return v + "Bar";
        } else {
            return "Bar";
        }
    }

    public String testGetAfterContainsKeyField() {

        if (fieldMap.containsKey("Foo")) {
            String v = fieldMap.get("Foo");
            return v + "Bar";
        } else {
            return "Bar";
        }
    }

    public String testGetAfterContainsKeyFromMethodCall() {

        if (fieldMap.containsKey(getAValue())) {
            String v = fieldMap.get(getAValue());
            return v + "Bar";
        } else {
            return "Bar";
        }
    }

    public String testRemoveAfterGetLocal(Map ss) {
        String s = ss.get("foo");
        ss.remove("foo");
        return s;
    }

    public String testRemoveAfterGetField() {
        String s = fieldMap.get("foo");
        fieldMap.remove("foo");
        return s;
    }

    public boolean testKeySetForNull(Map s) {
        return s.keySet() != null;
    }

    public void testUseContainsKey(Map m) {
        if (m.keySet().contains("Foo")) {
            System.out.println("Yup");
        }
    }

    public List testKeySetSize(Map m) {
        return new ArrayList<>(m.keySet().size());
    }

    public List testEntrySetSize(Map m) {
        return new ArrayList<>(m.entrySet().size());
    }

    public List testValuesSize(Map m) {
        return new ArrayList<>(m.values().size());
    }

    public String getAValue() {
        return MUI_Sample.class.getName();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy