Tabnine Logo
sirius.kernel.commons
Code IndexAdd Tabnine to your IDE (free)

How to use sirius.kernel.commons

Best Java code snippets using sirius.kernel.commons (Showing top 20 results out of 315)

origin: com.scireum/sirius-kernel

/**
 * Sets the given value (its string representation), mit limits this to <tt>limit</tt> characters.
 *
 * @param key   the key to which the value should be associated
 * @param value the value which string representation should be put into the context
 * @param limit the maximal number of characters to put into the map. Everything after that will be discarded
 */
public void putLimited(String key, Object value, int limit) {
  set(key, Strings.limit(value, limit));
}
origin: com.scireum/sirius-kernel

/**
 * Formats the represented value by rounding to zero decimal places. The rounding mode is obtained from
 * {@link NumberFormat#NO_DECIMAL_PLACES}.
 *
 * @return a rounded representation of this number using {@code NumberFormat#NO_DECIMAL_PLACES}
 * or "" is the value is empty.
 */
public String toRoundedString() {
  return toSmartRoundedString(NumberFormat.NO_DECIMAL_PLACES).toString();
}
origin: com.scireum/sirius-db

@Override
protected Object transformFromJDBC(Value data) {
  Object object = data.get();
  if (object == null) {
    return Amount.NOTHING;
  }
  if (object instanceof Double) {
    return Amount.of((Double) object);
  }
  return Amount.of((BigDecimal) object);
}
origin: com.scireum/sirius-db

@Override
protected Object transformFromElastic(Value data) {
  String valueAsString = data.asString();
  if (Strings.isEmpty(valueAsString)) {
    return Amount.NOTHING;
  }
  return Amount.of(new BigDecimal(valueAsString));
}
origin: com.scireum/sirius-kernel

/**
 * String representation of the value along with its unit (is necessary)
 *
 * @return a string representation of the value
 */
public String getValueAsString() {
  return Amount.of(value).toSmartRoundedString(NumberFormat.TWO_DECIMAL_PLACES).append(" ", unit).toString();
}
origin: com.scireum/sirius-kernel

private boolean parseModifier() throws ParseException {
  if (tokenizer.getType() != Tokenizer.IDENTIFIER) {
    return false;
  }
  if (in(start())) {
    parseStartModifier();
    return true;
  }
  if (in(end())) {
    parseEndModifier();
    return true;
  }
  return false;
}
origin: com.scireum/sirius-kernel

@Override
@SuppressWarnings("squid:S1185")
@Explain("We need to overwrite this to make it synchronized.")
public synchronized void put(K key, V value) {
  super.put(key, value);
}
origin: com.scireum/sirius-kernel

/**
 * Tries to convert the wrapped value to a roman numeral representation
 * This only works if the wrapped value can be converted to <tt>int</tt> and is &gt;0 and &lt;4000.
 *
 * @param defaultValue the value to be converted to roman numeral if the wrapped value can not be converted
 * @return a roman numeral representation of either the wrapped value or the defaultValue. values &gt;=4000 and
 * &lt;=0  are represented as an empty String
 */
public String asRomanNumeral(int defaultValue) {
  return RomanNumeral.toRoman(asInt(defaultValue));
}
origin: com.scireum/sirius-kernel

/**
 * Returns the <tt>Amount</tt> for the wrapped value.
 * <p>
 * If the wrapped value can be converted to a BigDecimal ({@link #getBigDecimal(java.math.BigDecimal)},
 * an <tt>Amount</tt> for the result is returned. Otherwise an empty <tt>Amount</tt> is returned.
 *
 * @return the wrapped value converted to <tt>Amount</tt>. The result might be an empty amount, if the wrapped
 * value is <tt>null</tt> or if no conversion was possible.
 * @see #getBigDecimal(java.math.BigDecimal)
 */
public Amount getAmount() {
  return Amount.of(getBigDecimal());
}
origin: com.scireum/sirius-kernel

private void parseModifiers() throws ParseException {
  do {
    tokenizer.nextToken();
    // ignore "," between modifiers
    //noinspection UnnecessaryParentheses,UnnecessaryParentheses
    if ((tokenizer.getType() == Tokenizer.SPECIAL) && in(MODIFIER_SEPARATOR)) {
      tokenizer.nextToken();
    }
  } while (parseModifier());
}
origin: com.scireum/sirius-search

/**
 * Determines if an entity is referenced by this field or not.
 * <p>
 * This is not be confused with {@link #isValueLoaded()} which indicates if the value has already been
 * loaded from the database.
 *
 * @return <tt>true</tt> if an entity is referenced, <tt>false</tt> otherwise
 */
public boolean isFilled() {
  return Strings.isFilled(id);
}
origin: com.scireum/sirius-kernel

private void parseDeltas(Calendar result) throws ParseException {
  while (tokenizer.getType() != Tokenizer.END_OF_INPUT) {
    parseDelta(result, tokenizer);
    tokenizer.nextToken();
  }
}
origin: com.scireum/sirius-kernel

/**
 * Determines if the wrapped value is not null.
 *
 * @return <tt>true</tt> if the wrapped value is neither <tt>null</tt> nor ""
 */
public boolean isFilled() {
  return !isEmptyString();
}
origin: com.scireum/sirius-kernel

  @Override
  public void onFailure(Throwable throwable) throws Exception {
    failureHandler.invoke(throwable);
  }
});
origin: com.scireum/sirius-kernel

@SuppressWarnings("unchecked")
@Override
public <P> Collection<P> getParts(Class<? extends P> partInterface) {
  return (Collection<P>) parts.get(partInterface);
}
origin: com.scireum/sirius-kernel

/**
 * Generates a random password with 7 characters length.
 *
 * @return a randomly generated password.
 */
public static String generatePassword() {
  return generateCode(7);
}
origin: com.scireum/sirius-kernel

  /**
   * Returns the effective date as string
   *
   * @return the effective date formatted as string with time information
   */
  public String getDateTime() {
    return getDateString(true);
  }
}
origin: com.scireum/sirius-kernel

/**
 * Creates a new <tt>ValueHolder</tt> with the given initial value.
 * <p>
 * This method can be used instead of a constructor, so that the type parameters don't need to be re-typed.
 *
 * @param initialValue sets the value of the value holder
 * @param <T>          the type of the value being held by this <tt>ValueHolder</tt>
 * @return a new ValueHolder initialized with the given value.
 */
public static <T> ValueHolder<T> of(T initialValue) {
  return new ValueHolder<>(initialValue);
}
origin: com.scireum/sirius-kernel

/**
 * Determines if this amount is greater than the given one.
 * <p>
 * See {@link #compareTo(Amount)} for an explanation of how empty amounts are handled.
 *
 * @param o the other amount to compare against
 * @return <tt>true</tt> if this amount is greater than the given one
 */
public boolean isGreaterThan(Amount o) {
  return compareTo(o) > 0;
}
origin: com.scireum/sirius-kernel

@Override
public String toString() {
  return toSmartRoundedString(NumberFormat.TWO_DECIMAL_PLACES).toString();
}
sirius.kernel.commons

Most used classes

  • Watch
    Provides a mechanism to measure the duration. Measures the duration between start and elapsed or dur
  • Limit
    Helper class to handle result windowing (start+limit) of arbitrary data sets. A Limit is used to pro
  • Monoflop
    Represents a boolean state variable, which can be toggled once from false to true. All successive c
  • Strings
    Provides various helper methods for dealing with Java Strings The Value class provides some addition
  • Tuple
    Represents a tuple of two values with two arbitrary types. If the first type is comparable and shoul
  • Amount,
  • Context,
  • Explain,
  • Lambdas,
  • RateLimit,
  • Reflection,
  • ValueHolder,
  • Values,
  • Wait,
  • Callback,
  • ComparableTuple,
  • Exec,
  • Files,
  • MultiMap
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now