src.samples.java.ex.STT_Sample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fb-contrib Show documentation
Show all versions of fb-contrib Show documentation
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.
package ex;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class STT_Sample {
enum Sample {
Hi, Lo
};
Map map = new HashMap<>();
String val;
public void testToStringToField() {
val = Sample.Hi.toString();
}
public void testSBWithToStringToField(Date d, Integer i) {
StringBuilder s = new StringBuilder();
s.append(d);
s.append(i);
val = s.toString();
}
public Object testSBToMapField(Date d1, Date d2) {
map.put("a-v", d1 + ":" + d2);
return map.get(d1 + "-" + d2);
}
public String testParseOfMapResult() {
String s = (String) map.get("foo");
int colonPos = s.indexOf(":");
return s.substring(0, colonPos);
}
public Map testLocalMapKeyedByStringifiedType(String a, String b) {
Map s = new HashMap<>();
s.put(a + b, b + a);
return s;
}
public void fpTestToStringToFieldSB(String s) {
val = s + "wow";
}
public void fpAllowUUID() {
val = UUID.randomUUID().toString();
}
}