Codota Logo
Types.asIterable
Code IndexAdd Codota to your IDE (free)

How to use
asIterable
method
in
js.util.Types

Best Java code snippets using js.util.Types.asIterable (Showing top 2 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: com.js-lib/js-xhtml-template

/**
 * Retrieve content array like instance as iterable. Delegates {@link #getValue(Object, String)} to obtain the requested
 * value. If value is null warn the event and return empty list. I value is array like return it as iterable, otherwise
 * throws content exception.
 * 
 * @param scope scope object,
 * @param propertyPath object property path.
 * @return array like instance, possible empty, converted to iterable.
 * @throws TemplateException if requested value is undefined or is not an {@link Types#isArrayLike(Object) an array like}.
 */
Iterable<?> getIterable(Object scope, String propertyPath) throws TemplateException {
  Object value = getValue(scope, propertyPath);
  if (value == null) {
    warn(scope.getClass(), propertyPath);
    return Collections.EMPTY_LIST;
  }
  if (!Types.isArrayLike(value)) {
    throw new TemplateException("Invalid type. Expected list but got |%s|.", value.getClass());
  }
  return Types.asIterable(value);
}
origin: com.js-lib/js-json

/**
 * Serialize opening square brace, array items separated by comma and closing square brace. This method invoked recursively
 * {@link #serialize(Object)} for every array item.
 * 
 * @param value
 * @throws IOException
 */
private void serializeArray(Object value) throws IOException {
  write('[');
  int index = 0;
  for (Object item : Types.asIterable(value)) {
    if (index++ > 0) {
      write(',');
    }
    serialize(item);
  }
  write(']');
}
js.utilTypesasIterable

Javadoc

Convert object instance to iterable. If object instance is an array or a collection returns an iterable instance able to iterate array respective collection items. Otherwise return an empty iterable.

This utility method is designed to be used with foreach loop. Note that if object instance is not iterable foreach loop is not executed.

 
Object o = getObjectFromSomeSource(); 
for(Object item : Types.asIterable(o)) { 
// do something with item instance 
} 

Popular methods of Types

  • isArrayLike
    Test if type is array like, that is, array or collection. Uses #isArray(Type) and #isCollection(Type
  • isMap
    Test if type is map. Returns true if type implements, directly or through inheritance, Map interface
  • isBoolean
    Test if type is a boolean primitive or boxing class.
  • isKindOf
    Determine if a given type is a kind of one of the requested types to match. Traverses typesToMatch a
  • isNumber
    Test if type is numeric. A type is considered numeric if is a Java standard class representing a num
  • isPrimitiveLike
    Test if type is like a primitive? Return true only if given type is a number, boolean, enumeration,
  • isArray
    Test if type is array. If type is a class return Class#isArray() predicate value; otherwise test if
  • isCollection
    Test if type is collection. Returns true if type implements, directly or through inheritance, Collec
  • isDate
    Test if type is a calendar date.
  • isEnum
    Test if type is enumeration. This predicate delegates Class#isEnum() if type is a class. If not, ret
  • isInstanceOf
    Test if object instance is not null and extends or implements expected type. This predicate consider
  • isPrimitive
    Test if type is primitive. Primitive types are those considered so by Class#isPrimitive().
  • isInstanceOf,
  • isPrimitive,
  • isVoid,
  • asBoolean,
  • equalsAny,
  • getEmptyValue,
  • isCharacter,
  • isConcrete,
  • isEqual

Popular in Java

  • Updating database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • putExtra (Intent)
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • HashSet (java.util)
    This class implements the Set interface, backed by a hash table (actually a HashMap instance). It m
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • Collectors (java.util.stream)
  • Option (scala)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now