本文整理了Java中org.springframework.core.Constants.<init>()
方法的一些代码示例,展示了Constants.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Constants.<init>()
方法的具体详情如下:
包路径:org.springframework.core.Constants
类名称:Constants
方法名:<init>
[英]Create a new Constants converter class wrapping the given class.
All public static final variables will be exposed, whatever their type.
[中]创建一个新的常量转换器类来包装给定的类。
所有公共静态最终变量都将公开,无论其类型如何。
代码示例来源:origin: spring-projects/spring-framework
@Test
public void getValuesWithNullPrefix() throws Exception {
Constants c = new Constants(A.class);
Set<?> values = c.getValues(null);
assertEquals("Must have returned *all* public static final values", 7, values.size());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void ctorWithNullClass() throws Exception {
try {
new Constants(null);
fail("Must have thrown IllegalArgumentException");
}
catch (IllegalArgumentException expected) {}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void getValuesWithEmptyStringPrefix() throws Exception {
Constants c = new Constants(A.class);
Set<Object> values = c.getValues("");
assertEquals("Must have returned *all* public static final values", 7, values.size());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void getValuesWithWhitespacedStringPrefix() throws Exception {
Constants c = new Constants(A.class);
Set<?> values = c.getValues(" ");
assertEquals("Must have returned *all* public static final values", 7, values.size());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void suffixAccess() {
Constants c = new Constants(A.class);
Set<?> names = c.getNamesForSuffix("_PROPERTY");
assertEquals(2, names.size());
assertTrue(names.contains("NO_PROPERTY"));
assertTrue(names.contains("YES_PROPERTY"));
Set<?> values = c.getValuesForSuffix("_PROPERTY");
assertEquals(2, values.size());
assertTrue(values.contains(Integer.valueOf(3)));
assertTrue(values.contains(Integer.valueOf(4)));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void getValues() {
Constants c = new Constants(A.class);
Set<?> values = c.getValues("");
assertEquals(7, values.size());
assertTrue(values.contains(Integer.valueOf(0)));
assertTrue(values.contains(Integer.valueOf(66)));
assertTrue(values.contains(""));
values = c.getValues("D");
assertEquals(1, values.size());
assertTrue(values.contains(Integer.valueOf(0)));
values = c.getValues("prefix");
assertEquals(2, values.size());
assertTrue(values.contains(Integer.valueOf(1)));
assertTrue(values.contains(Integer.valueOf(2)));
values = c.getValuesForProperty("myProperty");
assertEquals(2, values.size());
assertTrue(values.contains(Integer.valueOf(1)));
assertTrue(values.contains(Integer.valueOf(2)));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void getValuesInTurkey() {
Locale oldLocale = Locale.getDefault();
Locale.setDefault(new Locale("tr", ""));
try {
Constants c = new Constants(A.class);
Set<?> values = c.getValues("");
assertEquals(7, values.size());
assertTrue(values.contains(Integer.valueOf(0)));
assertTrue(values.contains(Integer.valueOf(66)));
assertTrue(values.contains(""));
values = c.getValues("D");
assertEquals(1, values.size());
assertTrue(values.contains(Integer.valueOf(0)));
values = c.getValues("prefix");
assertEquals(2, values.size());
assertTrue(values.contains(Integer.valueOf(1)));
assertTrue(values.contains(Integer.valueOf(2)));
values = c.getValuesForProperty("myProperty");
assertEquals(2, values.size());
assertTrue(values.contains(Integer.valueOf(1)));
assertTrue(values.contains(Integer.valueOf(2)));
}
finally {
Locale.setDefault(oldLocale);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void getNames() {
Constants c = new Constants(A.class);
Set<?> names = c.getNames("");
assertEquals(c.getSize(), names.size());
assertTrue(names.contains("DOG"));
assertTrue(names.contains("CAT"));
assertTrue(names.contains("S1"));
names = c.getNames("D");
assertEquals(1, names.size());
assertTrue(names.contains("DOG"));
names = c.getNames("d");
assertEquals(1, names.size());
assertTrue(names.contains("DOG"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void withClassThatExposesNoConstants() throws Exception {
Constants c = new Constants(NoConstants.class);
assertEquals(0, c.getSize());
final Set<?> values = c.getValues("");
assertNotNull(values);
assertEquals(0, values.size());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void constants() {
Constants c = new Constants(A.class);
assertEquals(A.class.getName(), c.getClassName());
assertEquals(9, c.getSize());
assertEquals(A.DOG, c.asNumber("DOG").intValue());
assertEquals(A.DOG, c.asNumber("dog").intValue());
assertEquals(A.CAT, c.asNumber("cat").intValue());
try {
c.asNumber("bogus");
fail("Can't get bogus field");
}
catch (Constants.ConstantException expected) {
}
assertTrue(c.asString("S1").equals(A.S1));
try {
c.asNumber("S1");
fail("Wrong type");
}
catch (Constants.ConstantException expected) {
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void toCode() {
Constants c = new Constants(A.class);
代码示例来源:origin: org.apache.camel/camel-spring
@Override
public void setSystemPropertiesModeName(String constantName) throws IllegalArgumentException {
super.setSystemPropertiesModeName(constantName);
Constants constants = new Constants(PropertyPlaceholderConfigurer.class);
this.systemPropertiesMode = constants.asNumber(constantName).intValue();
}
代码示例来源:origin: stackoverflow.com
public static Constants getInstance() {
if(instance == null)
instance = new Constants();
return instance;
}
代码示例来源:origin: stackoverflow.com
model.addAttribute("globalConstants", new Constants());
代码示例来源:origin: stackoverflow.com
HashMap<String,String> pairs= new HashMap<String,String>();
Constants constants= new Constants();
Field[] f = constants.getClass().getFields();
for (int i = 0; i < f.length; i++) {
pairs.put(f[i].getName().toLowerCase(),f[i].get(constants).toString());
}
System.out.println(pairs);
代码示例来源:origin: spring-cloud/spring-cloud-aws
public void setDefaultTransactionIsolationName(String constantName) {
if (constantName == null) {
throw new IllegalArgumentException("Isolation name must not be null");
}
Constants constants = new Constants(Connection.class);
setDefaultTransactionIsolation(constants.asNumber(PREFIX_ISOLATION + constantName).intValue());
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-aws-jdbc
public void setDefaultTransactionIsolationName(String constantName) {
if (constantName == null) {
throw new IllegalArgumentException("Isolation name must not be null");
}
Constants constants = new Constants(Connection.class);
setDefaultTransactionIsolation(constants.asNumber(PREFIX_ISOLATION + constantName).intValue());
}
代码示例来源:origin: stackoverflow.com
private static Constants mC=new Constants();
代码示例来源:origin: stackoverflow.com
Constants cons = new Constants();
imageUrls = cons.getImagePath(Path.toString());
代码示例来源:origin: apache/servicemix-bundles
private static final Constants constants = new Constants(CronTrigger.class);
内容来源于网络,如有侵权,请联系作者删除!