List of usage examples for java.lang Class getPackage
public Package getPackage()
From source file:org.tros.utils.Random.java
/** * Get a new puid./*from w w w . j a v a 2 s.co m*/ * * @param c * @param type * @return */ public synchronized static String getPUID(final Class<?> c, UuidIncrementType type) { String key = DEFAULT_KEY; switch (type) { case useClass: key = c.getName(); break; case usePackage: key = c.getPackage().getName(); break; } if (!COUNTERS.containsKey(key)) { COUNTERS.put(key, new AtomicLong(1)); } AtomicLong l = COUNTERS.get(key); Long l2 = l.getAndIncrement(); return key + "-" + l2.toString(); }
From source file:gr.abiss.calipso.tiers.util.ModelContext.java
public ModelContext(ModelRelatedResource resource, Class<?> domainClass) { String packageName = domainClass.getPackage().getName(); this.beansBasePackage = packageName.endsWith(".model") ? packageName.substring(0, packageName.indexOf(".model")) : packageName;/*from w w w.j a va2 s. com*/ this.name = getPath(domainClass); this.apiAnnotationMembers = getApiAnnotationMembers(domainClass); String parentProperty = resource.parentProperty(); this.parentClass = (Class<?>) ReflectionUtils.findField(domainClass, parentProperty).getType(); String parentName = getPath(parentClass); this.path = "/" + parentName + "/{peId}/" + this.name; this.modelType = (Class<?>) domainClass; this.modelIdType = EntityUtil.getIdType(domainClass); this.generatedClassNamePrefix = domainClass.getSimpleName().replace("Model", "").replace("Entity", ""); this.parentProperty = resource.parentProperty(); }
From source file:org.broadinstitute.gatk.queue.extensions.gatk.GATKExtensionsGenerator.java
/** * Returns true if the class is part of the GATK. * @param clazz Class to check./*from www . j a va 2 s . co m*/ * @return True if the class is part of the GATK. */ private boolean isGatkProgram(Class<?> clazz) { if (clazz.getPackage() == null) return false; String classPackage = clazz.getPackage().getName(); for (String gatkPackage : gatkPackages) if (classPackage.startsWith(gatkPackage)) return true; return false; }
From source file:com.sonicle.webtop.core.app.ServiceDescriptor.java
private Set<Class<?>> findSubTypesClassesOf(String targetPackage, Class subTypeOf) { Set<Class<?>> output = new HashSet<>(); Reflections reflections = new Reflections(new ConfigurationBuilder() .setUrls(ClasspathHelper.forPackage(targetPackage)).setScanners(new SubTypesScanner()) .filterInputsBy(new FilterBuilder().includePackage(targetPackage))); Set<Class<?>> classes = reflections.getSubTypesOf(subTypeOf); for (Class<?> clazz : classes) { if (clazz.getPackage().getName().startsWith(targetPackage)) { output.add(clazz);//from w w w .j a va 2 s .co m } } return output; }
From source file:api.wiki.WikiGenerator.java
private String javaDocLink(Method method) { Class<?> declaringClass = method.getDeclaringClass(); Package aPackage = declaringClass.getPackage(); Class<?>[] parameterTypes = method.getParameterTypes(); String groupIdSlashes = groupId.replace('.', '/'); String packageSlashes = aPackage.getName().replace('.', '/'); String parameterSlashes = stream(parameterTypes).map(Class::getName).collect(joining("-", "", "-")); String closestReleasedVersion = latestReleasedVersion(version); return "https://oss.sonatype.org/service/local/repositories/releases/archive/" + groupIdSlashes + "/" + artifactId + "/" + closestReleasedVersion + "/" + artifactId + "-" + closestReleasedVersion + "-javadoc.jar/!/" + packageSlashes + "/" + declaringClass.getSimpleName() + ".html#" + method.getName() + "-" + parameterSlashes; }
From source file:org.datalorax.populace.core.util.ImmutableTypeMap.java
private V getPackage(final Class<?> rawType) { if (rawType.isPrimitive()) { return getPackage("java.lang"); }// w ww. j ava 2 s . c o m return getPackage(rawType.getPackage().getName()); }
From source file:org.brushingbits.jnap.struts2.config.RestControllerConfigBuilder.java
/** * TODO//from w ww .ja va2s . co m * * @param controllerClass * @return */ protected String determineControllerNamespace(Class<?> controllerClass) { String controllerPkgName = controllerClass.getPackage().getName(); String namespace = ""; if (controllerClass.isAnnotationPresent(Namespace.class)) { namespace = controllerClass.getAnnotation(Namespace.class).value(); } else if (controllerPkgName.length() > this.packageLocatorsBasePackage.length()) { namespace = controllerPkgName.substring(this.packageLocatorsBasePackage.length()); namespace = namespace.replaceAll("\\.", "/"); } return namespace; }
From source file:org.echocat.jemoni.jmx.JmxRegistry.java
@Nonnull public ObjectName getObjectNameFor(@Nonnull Class<?> type, @Nullable String instance, @Nullable String variant) { final StringBuilder sb = new StringBuilder(); final Package aPackage = type.getPackage(); final String packageName = aPackage != null ? aPackage.getName() : null; final String typeName = type.getName(); if (!isEmpty(packageName)) { sb.append(packageName);//from w w w . j a v a 2s . c o m sb.append(!isEmpty(variant) ? ":type=" : ":name="); sb.append(typeName.substring(packageName.length() + 1)); } else { sb.append("_"); sb.append(!isEmpty(variant) ? ":type=" : ":name="); sb.append(typeName); } if (!isEmpty(instance)) { sb.append('.').append(normalize(instance)); } if (!isEmpty(variant)) { sb.append(",name=").append(normalize(variant)); } try { return new ObjectName(sb.toString()); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException( "Could not create a valid object name for " + typeName + " and variant '" + variant + "'.", e); } }
From source file:org.yamj.common.model.YamjInfo.java
@SuppressWarnings("rawtypes") public YamjInfo(Class myClass) { // YAMJ Stuff this.projectName = myClass.getPackage().getImplementationVendor(); this.projectVersion = myClass.getPackage().getImplementationVersion(); this.moduleName = myClass.getPackage().getImplementationTitle(); this.moduleDescription = myClass.getPackage().getSpecificationTitle(); if (myClass.getPackage().getSpecificationVendor() != null) { this.buildDateTime = DateTimeTools.parseDate(myClass.getPackage().getSpecificationVendor(), DateTimeTools.BUILD_FORMAT); } else {/*ww w. j a v a 2s . c o m*/ this.buildDateTime = new DateTime(); } this.buildRevision = myClass.getPackage().getSpecificationVersion(); // System Stuff this.processorCores = Runtime.getRuntime().availableProcessors(); this.javaVersion = SystemUtils.JAVA_VERSION; this.osArch = SystemUtils.OS_ARCH; this.osName = SystemUtils.OS_NAME; this.osVersion = SystemUtils.OS_VERSION; // Times this.startUpDateTime = new DateTime(ManagementFactory.getRuntimeMXBean().getStartTime()); // Counts this.counts = new EnumMap<MetaDataType, Long>(MetaDataType.class); // IP Address this.coreIp = SystemTools.getIpAddress(Boolean.TRUE); // Core Port this.corePort = 8888; // TODO: Get this from jetty! // Database IP & Name findDatabaseInfo(); this.baseArtworkUrl = buildBaseUrl(PropertyTools.getProperty("yamj3.file.storage.artwork", "")); this.baseMediainfoUrl = buildBaseUrl(PropertyTools.getProperty("yamj3.file.storage.mediainfo", "")); this.basePhotoUrl = buildBaseUrl(PropertyTools.getProperty("yamj3.file.storage.photo", "")); this.skinDir = buildBaseUrl(PropertyTools.getProperty("yamj3.file.storage.skins", "./skins/")); }
From source file:org.atemsource.atem.impl.pojo.PojoEntityTypeRepository.java
protected boolean isAvailable(Class clazz) { return (entityClass == null || entityClass.isAssignableFrom(clazz)) && (includedPackage == null || (clazz.getPackage() != null && clazz.getPackage().getName().startsWith(includedPackage))); }