Java Code Examples for java.lang.reflect.Constructor#getName()
The following examples show how to use
java.lang.reflect.Constructor#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableRelation.java From baleen with Apache License 2.0 | 6 votes |
private Entity getEntity(JCas jCas, TableCell cell, Constructor<? extends Entity> type) { List<? extends Entity> covered = JCasUtil.selectCovered(type.getDeclaringClass(), cell); if (!covered.isEmpty()) { return covered.get(0); } else { Entity entity; try { entity = type.newInstance(jCas); entity.setBegin(cell.getBegin()); entity.setEnd(cell.getEnd()); entity.setValue(cell.getCoveredText()); if (!Strings.isNullOrEmpty(subType)) { entity.setSubType(subType); } addToJCasIndex(entity); return entity; } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new BaleenRuntimeException("Can not create entity type " + type.getName(), e); } } }
Example 2
Source File: BukkitReflect.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
static Object invokeConstuctor(Constructor<?> constuctor, Object... args) { try { return constuctor.newInstance(args); } catch (Exception e) { throw new RuntimeException("Error while invoking " + constuctor.getName() + ".", e); } }
Example 3
Source File: Inspector.java From groovy with Apache License 2.0 | 5 votes |
protected String[] methodInfo(Constructor ctor) { String[] result = new String[MEMBER_EXCEPTIONS_IDX + 1]; result[MEMBER_ORIGIN_IDX] = JAVA; result[MEMBER_MODIFIER_IDX] = Modifier.toString(ctor.getModifiers()); result[MEMBER_DECLARER_IDX] = shortName(ctor.getDeclaringClass()); result[MEMBER_TYPE_IDX] = shortName(ctor.getDeclaringClass()); result[MEMBER_NAME_IDX] = ctor.getName(); result[MEMBER_PARAMS_IDX] = makeParamsInfo(ctor.getParameterTypes()); result[MEMBER_EXCEPTIONS_IDX] = makeExceptionInfo(ctor.getExceptionTypes()); return withoutNulls(result); }
Example 4
Source File: ObjectStreamClass.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public MemberSignature(Constructor<?> cons) { member = cons; name = cons.getName(); signature = getMethodSignature( cons.getParameterTypes(), Void.TYPE); }
Example 5
Source File: TypeExtractionUtils.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public LambdaExecutable(Constructor<?> constructor) { this.parameterTypes = constructor.getGenericParameterTypes(); this.returnType = constructor.getDeclaringClass(); this.name = constructor.getName(); this.executable = constructor; }
Example 6
Source File: ObjectStreamClass.java From Bytecoder with Apache License 2.0 | 4 votes |
public MemberSignature(Constructor<?> cons) { member = cons; name = cons.getName(); signature = getMethodSignature( cons.getParameterTypes(), Void.TYPE); }
Example 7
Source File: ObjectStreamClass.java From Java8CN with Apache License 2.0 | 4 votes |
public MemberSignature(Constructor<?> cons) { member = cons; name = cons.getName(); signature = getMethodSignature( cons.getParameterTypes(), Void.TYPE); }
Example 8
Source File: ObjectStreamClass.java From jdk-1.7-annotated with Apache License 2.0 | 4 votes |
public MemberSignature(Constructor cons) { member = cons; name = cons.getName(); signature = getMethodSignature( cons.getParameterTypes(), Void.TYPE); }
Example 9
Source File: AccessPermissionChecker.java From groovy with Apache License 2.0 | 4 votes |
private static CacheAccessControlException createCacheAccessControlExceptionOf(Constructor constructor, AccessControlException e) { return new CacheAccessControlException( "Groovy object can not access constructor " + constructor.getName() + " cacheAccessControlExceptionOf class " + constructor.getDeclaringClass().getName() + " with modifiers \"" + Modifier.toString(constructor.getModifiers()) + "\"", e); }
Example 10
Source File: ObjectStreamClass.java From hottub with GNU General Public License v2.0 | 4 votes |
public MemberSignature(Constructor<?> cons) { member = cons; name = cons.getName(); signature = getMethodSignature( cons.getParameterTypes(), Void.TYPE); }
Example 11
Source File: ObjectStreamClass.java From JDKSourceCode1.8 with MIT License | 4 votes |
public MemberSignature(Constructor<?> cons) { member = cons; name = cons.getName(); signature = getMethodSignature( cons.getParameterTypes(), Void.TYPE); }
Example 12
Source File: JavadocParanamer.java From stategen with GNU Affero General Public License v3.0 | 4 votes |
public String[] lookupParameterNames(AccessibleObject methodOrConstructor, boolean throwExceptionIfMissing) { if (methodOrConstructor == null) throw new NullPointerException(); Class<?> klass; String name; Class<?>[] types; if (methodOrConstructor instanceof Constructor<?>) { Constructor<?> constructor = (Constructor<?>) methodOrConstructor; klass = constructor.getDeclaringClass(); name = constructor.getName(); types = constructor.getParameterTypes(); } else if (methodOrConstructor instanceof Method) { Method method = (Method) methodOrConstructor; klass = method.getDeclaringClass(); name = method.getName(); types = method.getParameterTypes(); } else throw new IllegalArgumentException(); // quick check to see if we support the package if (!packages.contains(klass.getPackage().getName())) throw CLASS_NOT_SUPPORTED; try { String[] names = getParameterNames(klass, name, types); if (names == null) { if (throwExceptionIfMissing) { throw new ParameterNamesNotFoundException( methodOrConstructor.toString()); } else { return Paranamer.EMPTY_NAMES; } } return names; } catch (IOException e) { if (throwExceptionIfMissing) { throw new ParameterNamesNotFoundException( methodOrConstructor.toString() + " due to an I/O error: " + e.getMessage()); } else { return Paranamer.EMPTY_NAMES; } } }
Example 13
Source File: ObjectStreamClass.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public MemberSignature(Constructor<?> cons) { member = cons; name = cons.getName(); signature = getMethodSignature( cons.getParameterTypes(), Void.TYPE); }
Example 14
Source File: PoseidonLegoSet.java From Poseidon with Apache License 2.0 | 4 votes |
private void resolveInjectableConstructorDependencies(Constructor<?> constructor, Object[] initParams, int offset, Optional<Request> request) throws MissingInformationException, ElementNotFoundException { for (int i = offset; i < constructor.getParameterCount(); i++) { final Parameter constructorParameter = constructor.getParameters()[i]; final RequestAttribute requestAttribute = constructorParameter.getAnnotation(RequestAttribute.class); final com.flipkart.poseidon.datasources.ServiceClient serviceClientAttribute = constructorParameter.getAnnotation(com.flipkart.poseidon.datasources.ServiceClient.class); final SystemDataSource systemDataSourceAttribute = constructorParameter.getAnnotation(SystemDataSource.class); if (requestAttribute != null) { final String attributeName = StringUtils.isNullOrEmpty(requestAttribute.value()) ? constructorParameter.getName() : requestAttribute.value(); initParams[i] = request.map(r -> r.getAttribute(attributeName)).map(attr -> { if (constructorParameter.getType().isAssignableFrom(attr.getClass())) { return attr; } else { return mapper.convertValue(attr, mapper.constructType(constructorParameter.getParameterizedType())); } }).orElse(null); } else if (serviceClientAttribute != null) { ServiceClient serviceClient = serviceClientsByName.get(constructor.getParameterTypes()[i].getName()); if (serviceClient == null) { throw new ElementNotFoundException("Unable to find ServiceClient for class = " + constructor.getParameterTypes()[i]); } initParams[i] = serviceClient; } else if (systemDataSourceAttribute != null) { final DataSource<?> systemDataSource = systemDataSources.get(systemDataSourceAttribute.value()); if (systemDataSource == null) { throw new ElementNotFoundException("Unable to find SystemDataSource for id = " + systemDataSourceAttribute.value()); } initParams[i] = systemDataSource; } else { final Qualifier qualifier = constructorParameter.getAnnotation(Qualifier.class); String beanName = null; if (qualifier != null && !StringUtils.isNullOrEmpty(qualifier.value())) { beanName = qualifier.value(); } initParams[i] = beanName == null ? context.getBean(constructor.getParameterTypes()[i]) : context.getBean(beanName, constructor.getParameterTypes()[i]); if (initParams[i] == null) { throw new MissingInformationException("Unmet dependency for constructor " + constructor.getName() + ": " + constructor.getParameterTypes()[i].getCanonicalName()); } } } }
Example 15
Source File: ObjectStreamClass.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public MemberSignature(Constructor<?> cons) { member = cons; name = cons.getName(); signature = getMethodSignature( cons.getParameterTypes(), Void.TYPE); }
Example 16
Source File: MBeanConstructorInfo.java From TencentKona-8 with GNU General Public License v2.0 | 2 votes |
/** * Constructs an <CODE>MBeanConstructorInfo</CODE> object. The * {@link Descriptor} of the constructed object will include * fields contributed by any annotations on the {@code * Constructor} object that contain the {@link DescriptorKey} * meta-annotation. * * @param description A human readable description of the operation. * @param constructor The <CODE>java.lang.reflect.Constructor</CODE> * object describing the MBean constructor. */ public MBeanConstructorInfo(String description, Constructor<?> constructor) { this(constructor.getName(), description, constructorSignature(constructor), Introspector.descriptorForElement(constructor)); }
Example 17
Source File: MBeanConstructorInfo.java From openjdk-jdk8u with GNU General Public License v2.0 | 2 votes |
/** * Constructs an <CODE>MBeanConstructorInfo</CODE> object. The * {@link Descriptor} of the constructed object will include * fields contributed by any annotations on the {@code * Constructor} object that contain the {@link DescriptorKey} * meta-annotation. * * @param description A human readable description of the operation. * @param constructor The <CODE>java.lang.reflect.Constructor</CODE> * object describing the MBean constructor. */ public MBeanConstructorInfo(String description, Constructor<?> constructor) { this(constructor.getName(), description, constructorSignature(constructor), Introspector.descriptorForElement(constructor)); }
Example 18
Source File: MBeanConstructorInfo.java From dragonwell8_jdk with GNU General Public License v2.0 | 2 votes |
/** * Constructs an <CODE>MBeanConstructorInfo</CODE> object. The * {@link Descriptor} of the constructed object will include * fields contributed by any annotations on the {@code * Constructor} object that contain the {@link DescriptorKey} * meta-annotation. * * @param description A human readable description of the operation. * @param constructor The <CODE>java.lang.reflect.Constructor</CODE> * object describing the MBean constructor. */ public MBeanConstructorInfo(String description, Constructor<?> constructor) { this(constructor.getName(), description, constructorSignature(constructor), Introspector.descriptorForElement(constructor)); }
Example 19
Source File: MBeanConstructorInfo.java From openjdk-8 with GNU General Public License v2.0 | 2 votes |
/** * Constructs an <CODE>MBeanConstructorInfo</CODE> object. The * {@link Descriptor} of the constructed object will include * fields contributed by any annotations on the {@code * Constructor} object that contain the {@link DescriptorKey} * meta-annotation. * * @param description A human readable description of the operation. * @param constructor The <CODE>java.lang.reflect.Constructor</CODE> * object describing the MBean constructor. */ public MBeanConstructorInfo(String description, Constructor<?> constructor) { this(constructor.getName(), description, constructorSignature(constructor), Introspector.descriptorForElement(constructor)); }
Example 20
Source File: MBeanConstructorInfo.java From jdk8u_jdk with GNU General Public License v2.0 | 2 votes |
/** * Constructs an <CODE>MBeanConstructorInfo</CODE> object. The * {@link Descriptor} of the constructed object will include * fields contributed by any annotations on the {@code * Constructor} object that contain the {@link DescriptorKey} * meta-annotation. * * @param description A human readable description of the operation. * @param constructor The <CODE>java.lang.reflect.Constructor</CODE> * object describing the MBean constructor. */ public MBeanConstructorInfo(String description, Constructor<?> constructor) { this(constructor.getName(), description, constructorSignature(constructor), Introspector.descriptorForElement(constructor)); }