本文整理了Java中java.lang.reflect.Constructor.getModifiers()
方法的一些代码示例,展示了Constructor.getModifiers()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Constructor.getModifiers()
方法的具体详情如下:
包路径:java.lang.reflect.Constructor
类名称:Constructor
方法名:getModifiers
[英]Returns the modifiers for this constructor. The Modifier class should be used to decode the result.
[中]返回此构造函数的修饰符。应该使用修饰符类来解码结果。
代码示例来源:origin: spring-projects/spring-framework
/**
* Make the given constructor accessible, explicitly setting it accessible
* if necessary. The {@code setAccessible(true)} method is only called
* when actually necessary, to avoid unnecessary conflicts with a JVM
* SecurityManager (if active).
* @param ctor the constructor to make accessible
* @see java.lang.reflect.Constructor#setAccessible
*/
@SuppressWarnings("deprecation") // on JDK 9
public static void makeAccessible(Constructor<?> ctor) {
if ((!Modifier.isPublic(ctor.getModifiers()) ||
!Modifier.isPublic(ctor.getDeclaringClass().getModifiers())) && !ctor.isAccessible()) {
ctor.setAccessible(true);
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new DurationFormatUtils());
final Constructor<?>[] cons = DurationFormatUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(DurationFormatUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(DurationFormatUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new Validate());
final Constructor<?>[] cons = Validate.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(Validate.class.getModifiers()));
assertFalse(Modifier.isFinal(Validate.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new SystemUtils());
final Constructor<?>[] cons = SystemUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(SystemUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(SystemUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new ExceptionUtils());
final Constructor<?>[] cons = ExceptionUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ExceptionUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(ExceptionUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new DateUtils());
final Constructor<?>[] cons = DateUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(DateUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(DateUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new SerializationUtils());
final Constructor<?>[] cons = SerializationUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(SerializationUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(SerializationUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new DateFormatUtils());
final Constructor<?>[] cons = DateFormatUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(DateFormatUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(DateFormatUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new ArrayUtils());
final Constructor<?>[] cons = ArrayUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ArrayUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(ArrayUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new ObjectUtils());
final Constructor<?>[] cons = ObjectUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ObjectUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(ObjectUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new CharSequenceUtils());
final Constructor<?>[] cons = CharSequenceUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(CharSequenceUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(CharSequenceUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Test that constructors are public, and work, etc.
*/
@Test
public void testConstructor() {
assertNotNull(new LocaleUtils());
final Constructor<?>[] cons = LocaleUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(LocaleUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(LocaleUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new ClassUtils());
final Constructor<?>[] cons = ClassUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ClassUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(ClassUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new CharUtils());
final Constructor<?>[] cons = CharUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(BooleanUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(BooleanUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new StringUtils());
final Constructor<?>[] cons = StringUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(StringUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(StringUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new EventUtils());
final Constructor<?>[] cons = EventUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(EventUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(EventUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new WordUtils());
final Constructor<?>[] cons = WordUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(WordUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(WordUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new FieldUtils());
final Constructor<?>[] cons = FieldUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(FieldUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(FieldUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new RandomStringUtils());
final Constructor<?>[] cons = RandomStringUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(RandomStringUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(RandomStringUtils.class.getModifiers()));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testConstructor() {
assertNotNull(new BooleanUtils());
final Constructor<?>[] cons = BooleanUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(BooleanUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(BooleanUtils.class.getModifiers()));
}
内容来源于网络,如有侵权,请联系作者删除!