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

src.samples.java.ex.PDP_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.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("all")
public class PDP_Sample {
    ArrayList al;

    public PDP_Sample(List l) {
        al = (ArrayList) l;
    }

    private void testFPCodeChecksType(List l) {
        if (l instanceof ArrayList) {
            al = (ArrayList) l;
        }
    }

    private void testFPNonParm(String s) {
        List l = new ArrayList<>();
        al = (ArrayList) l;
    }

    private void testDoubleInSig(double d, List l) {
        al = (ArrayList) l;
    }

    public static void testStatic(long lng, List l) {
        ArrayList aal = (ArrayList) l;
    }

    protected void testFPDerivableMethod(List l) {
        al = (ArrayList) l;
    }

    public static void testMultiCasts(String key, Object o) {
        if (key.equals("Foo")) {
            double d = ((Double) o).doubleValue();
        } else if (key.equals("Boo")) {
            float f = ((Float) o).floatValue();
        }
    }

    public static String testFPFlimsyIfGuard(Comparable c, boolean isNumber) {
        String s = c.toString();
        if (isNumber) {
            Number n = (Number) c;
            s += n.intValue();
        }

        return s;
    }

    private String testFPTableSwitchGuard(Comparable c, int type) {
        String s = "";

        switch (type) {
            case 0:
                Number n = (Number) c;
                s += n.intValue();
            break;

            case 1:
                s += s;
            break;

            case 2:
                s += "0";
            break;

            case 3:
                s += '3';
            break;

            case 4:
                s = null;
            break;

            case 5:
                s = s.substring(0, 1);
            break;
        }

        return s;
    }

    private String testFPLookupSwitch(Comparable c, int type) {
        String s = "";

        switch (type) {
            case 0:
                Number n = (Number) c;
                s += n.intValue();
            break;

            case 1000:
                s += s;
            break;

            case 10000:
                s += "0";
            break;
        }

        return s;
    }

    interface LambdaConstrained {
        void doIt(Number n);
    }

    public void usesLambda(LambdaConstrained c) {
    }

    public void fpConstrainedByLambda() {
        usesLambda((n) -> {
            BigDecimal d = ((BigDecimal) n);
            d = d.setScale(10);
            System.out.println(d);
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy