/** * Gets the bundle from the corresponding module according to the bundle support. * * @param support the bundle support * @param locale the locale * @return the bundle */ protected ResourceBundle getBundle(BundleSupport support, Locale locale) { return support.getModuleInfo().getHook().getBundle(support.getBundleName(), locale); }
/** * Creates a class mapper for a given mapped service name. * * @param name the mapper's name * @param mappedServiceName the mapped name */ public DefaultClassMapper(String name, String mappedServiceName) { this(name, ServiceFactory.getClassLoader(Constants.MAPPED_SERVICE_PATH, mappedServiceName), ServiceFactory.getServiceFinder().createNameMap(mappedServiceName), null); }
/** * Asserts that a thread local Locale is set.<br> * @throws TentackleRuntimeException if thread-local locale is null */ public void assertCurrentLocaleValid() { if (getCurrentLocale() == null) { throw new TentackleRuntimeException("no thread local Locale"); } }
/** * Gets the bundle. * * @return the resource bundle */ public static ResourceBundle getBundle() { return BundleFactory.getBundle(ValidationBundle.class.getName(), LocaleProvider.getInstance().getLocale()); }
/** * Check the scale of the given money value. * If it does not match the scale of this object, * scale it to the current scale of this object. * * @param val the value to be checked * @return the re-scaled value or the value itself if no rescaling necessary */ protected BMoney alignScale(BMoney val) { return val.scale() == scale() ? val : new BMoney(val.unscaledValue(), scale()); }
/** * Default implementation for a remote session factory. * * @author harald */ @Service(RemoteSessionFactory.class) public class DbRemoteSessionFactory implements RemoteSessionFactory { @Override public RemoteSession create(RemoteDbSession remoteDbSession) { return new RemoteSessionAdapter(remoteDbSession); } }
private void assertNotFrozen() { if (frozen) { throw new TentackleRuntimeException("date is frozen"); } }
/** * Divides a BMoney by this value and returns a new object. * This object remains unchanged. * * @param val the money value to multiply * @return the quotient of this and given value */ public double divide(BMoney val) { return doubleValue() / val.doubleValue(); }
/** * checks if a string contains only digits, i.e. * no non-number char in string, even no whitespace. * * @param str the string to check * * @return true if no illegal char detected, false otherwise */ public static boolean isAllDigits(String str) { return isAllDigits(str, false); }
/** * Gets the classloader for the given service name. * * @param serviceName the service name * @return the loader, never null */ protected ClassLoader getClassLoader(String serviceName) { ClassLoader cl = ServiceFactory.getExplicitClassLoader(servicePath, serviceName); if (cl == null) { cl = getClassLoader(); } return cl; }
/** * Gets the basename of a classname(-like) string. * The basename is the last name of a pathname with dots. * * @param str the classname * @return the basename */ public static String getClassBaseName(String str) { return StringHelper.lastAfter(str, '.'); }
/** * Gets the absolute value. * * @return the absolute (positive) value */ public BMoney absolute() { return isNegative() ? invert() : this; }
/** * Checks if this money value is positive. * * @return true if number is positive */ public boolean isPositive() { return signum() > 0; }
/** * Normalizes a string (phonetically) for use as PDO.normText * using {@link #stringNormalizer}. * * @param str the string to be normalized * @return the normalized string */ public static String normalize (String str) { return normalize(str, null); }
/** * Gets a service finder for a given service path.<br> * If the finder does not exist yet, it will be created. * The classloader used is {@code Thread.currentThread().getContextClassLoader()}. * * @param servicePath the service path prefix * @return the finder, never null */ public static ServiceFinder getServiceFinder(String servicePath) { return INSTANCE.getServiceFinderImpl(servicePath); }
/** * The default classmapper factory. * * @author harald */ @Service(ClassMapperFactory.class) public class DefaultClassMapperFactory implements ClassMapperFactory { @Override public ClassMapper create(String name, Class<?> mappedClass) { return new DefaultClassMapper(name, mappedClass); } }
/** * Asserts that end ist valid. * <p> * The end is valid if {@link #end()} has been invoked. */ protected void assertDurationValid() { if (!durationValid) { throw new TentackleRuntimeException("duration not valid"); } }
/** * Checks if this money value is zero. * * @return true if number is zero */ public boolean isZero() { return signum() == 0; }