private static Environment cacheCurrentEnvironment() { Environment env = resolveCurrentEnvironment(); cachedCurrentEnvironment.set(env); return env; }
/** * @see #getCurrent() * @return the current environment */ public static Environment getCurrentEnvironment() { return getCurrent(); }
/** * Converts foo-bar into fooBar. * * @param name The lower case hyphen separated name * @return The property name equivalent */ public static String getPropertyNameForLowerCaseHyphenSeparatedName(String name) { return getPropertyName(getClassNameForLowerCaseHyphenSeparatedName(name)); }
/** * Returns the property name equivalent for the specified class. * * @param targetClass The class to get the property name for * @return A property name reperesentation of the class name (eg. MyClass becomes myClass) */ public static String getPropertyNameRepresentation(Class<?> targetClass) { return getPropertyNameRepresentation(getShortName(targetClass)); }
/** * Shorter version of getPropertyNameRepresentation. * @param name The name to convert * @return The property name version */ public static String getPropertyName(String name) { return getPropertyNameRepresentation(name); }
/** * @return Whether a reload location is specified */ public boolean hasReloadLocation() { getReloadLocation(); return hasLocation(reloadLocation); }
public GrailsHibernateDomainClassProperty(GrailsHibernateDomainClass domainClass, String propertyName) { this.domainClass = domainClass; name = propertyName; naturalName = GrailsNameUtils.getNaturalName(propertyName); }
/** * This method will return true if the 'grails-app' directory was found, regardless of whether reloading is active or not * * @return True if the development sources are present */ public static boolean isDevelopmentEnvironmentAvailable() { return BuildSettings.GRAILS_APP_DIR_PRESENT && !isStandaloneDeployed() && !isWarDeployed(); }
/** * Check whether the application is deployed * @return true if is */ public static boolean isWarDeployed() { if(!isStandalone()) { return WAR_DEPLOYED; } return false; }
/** * Calculate the name for a getter method to retrieve the specified property * @param propertyName * @return The name for the getter method for this property, if it were to exist, i.e. getConstraints */ public static String getGetterName(String propertyName) { final String suffix = getSuffixForGetterOrSetter(propertyName); return PROPERTY_GET_PREFIX + suffix; }
/** * Returns an appropriate property name for the given object. If the object is a collection will append List, Set, Collection or Map to the property name * @param object The object * @return The property name convention */ public static String getPropertyNameConvention(Object object) { String suffix = ""; return getPropertyNameConvention(object, suffix); }
/** * Returns a property name equivalent for the given getter name or null if it is not a valid getter. If not null * or empty the getter name is assumed to be a valid identifier. * * @param getterName The getter name * @return The property name equivalent */ public static String getPropertyForGetter(String getterName) { return getPropertyForGetter(getterName, boolean.class); }
/** * Returns true if the name of the method specified and the number of arguments make it a javabean property getter. * The name is assumed to be a valid Java method name, that is not verified. * * @param name The name of the method * @param args The arguments * @return true if it is a javabean property getter * @deprecated use {@link #isGetter(String, Class, Class[])} instead because this method has a defect for "is.." method with Boolean return types. */ public static boolean isGetter(String name, Class<?>[] args) { return isGetter(name, boolean.class, args); }
/** * Calculates the class name from a script name in the form my-funk-grails-script. * * @param scriptName The script name * @return A class name */ public static String getNameFromScript(String scriptName) { return getClassNameForLowerCaseHyphenSeparatedName(scriptName); }
/** * Return the class name for the given logical name. For example "person" would evaluate to "Person" * * @param logicalName The logical name * @return The class name */ public static String getClassName(String logicalName) { return getClassName(logicalName, ""); }
/** * @return Return true if the environment has been set as a System property */ public static boolean isSystemSet() { return getEnvironment() != null; }
/** * Shorter version of getPropertyNameRepresentation. * @param clazz The clazz to convert * @return The property name version */ public static String getPropertyName(Class<?> clazz) { return getPropertyNameRepresentation(clazz); }
/** * Whether the application is running standalone within a JAR * * This method will return true only if the the application is executed via `java -jar` * and not if it is run via the main method within an IDE * * @return True if it is running standalone outside a servlet container from within a JAR or WAR file */ public static boolean isStandaloneDeployed() { return isStandalone() && STANDALONE_DEPLOYED; }
/** * Retrieves the name of a setter for the specified property name * @param propertyName The property name * @return The setter equivalent */ public static String getSetterName(String propertyName) { final String suffix = getSuffixForGetterOrSetter(propertyName); return PROPERTY_SET_PREFIX+suffix; }