congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ModuleItem.getDefaultValue
Code IndexAdd Tabnine to your IDE (free)

How to use
getDefaultValue
method
in
org.scijava.module.ModuleItem

Best Java code snippets using org.scijava.module.ModuleItem.getDefaultValue (Showing top 5 results out of 315)

origin: org.scijava/scijava-common

@Override
public <T> T getDefaultValue(final ModuleItem<T> item) {
  final T defaultValue = item.getDefaultValue();
  if (defaultValue != null) return defaultValue;
  final T min = item.getMinimumValue();
  if (min != null) return min;
  final T softMin = item.getSoftMinimum();
  if (softMin != null) return softMin;
  final T max = item.getMaximumValue();
  if (max != null) return max;
  final T softMax = item.getSoftMaximum();
  if (softMax != null) return softMax;
  if (Number.class.isAssignableFrom(item.getType())) {
    final T zero = convertService.convert("0", item.getType());
    if (zero != null) return zero;
  }
  // no known default value
  return null;
}
origin: scijava/scijava-common

@Override
public <T> T getDefaultValue(final ModuleItem<T> item) {
  final T defaultValue = item.getDefaultValue();
  if (defaultValue != null) return defaultValue;
  final T min = item.getMinimumValue();
  if (min != null) return min;
  final T softMin = item.getSoftMinimum();
  if (softMin != null) return softMin;
  final T max = item.getMaximumValue();
  if (max != null) return max;
  final T softMax = item.getSoftMaximum();
  if (softMax != null) return softMax;
  if (Number.class.isAssignableFrom(item.getType())) {
    final T zero = convertService.convert("0", item.getType());
    if (zero != null) return zero;
  }
  // no known default value
  return null;
}
origin: org.scijava/scijava-common

@Override
public <T> void save(final ModuleItem<T> item, final T value) {
  if (!item.isPersisted()) return;
  if (Objects.equals(item.getDefaultValue(), value)) {
    // NB: Do not persist the value if it is the default.
    // This is nice if the default value might change later,
    // such as when iteratively developing a script.
    prefService.remove(prefClass(item), prefKey(item));
    return;
  }
  final String sValue = value == null ? "" : convertService.convert(value, String.class);
  // do not persist if object cannot be converted back from a string
  if (!convertService.supports(sValue, item.getType())) return;
  prefService.put(prefClass(item), prefKey(item), sValue);
}
origin: scijava/scijava-common

@Override
public <T> void save(final ModuleItem<T> item, final T value) {
  if (!item.isPersisted()) return;
  if (Objects.equals(item.getDefaultValue(), value)) {
    // NB: Do not persist the value if it is the default.
    // This is nice if the default value might change later,
    // such as when iteratively developing a script.
    prefService.remove(prefClass(item), prefKey(item));
    return;
  }
  final String sValue = value == null ? "" : convertService.convert(value, String.class);
  // do not persist if object cannot be converted back from a string
  if (!convertService.supports(sValue, item.getType())) return;
  prefService.put(prefClass(item), prefKey(item), sValue);
}
origin: scijava/scijava-common

private void assertItem(final String name, final Class<?> type,
  final String label, final ItemIO ioType, final boolean required,
  final boolean persist, final String persistKey, final String style,
  final Object value, final Object min, final Object max,
  final Object softMin, final Object softMax, final Number stepSize,
  final List<?> choices, final ModuleItem<?> item)
{
  assertEquals(name, item.getName());
  assertSame(type, item.getType());
  assertEquals(label, item.getLabel());
  assertSame(ioType, item.getIOType());
  assertEquals(required, item.isRequired());
  assertEquals(persist, item.isPersisted());
  assertEquals(persistKey, item.getPersistKey());
  assertEquals(style, item.getWidgetStyle());
  assertEquals(value, item.getDefaultValue());
  assertEquals(min, item.getMinimumValue());
  assertEquals(max, item.getMaximumValue());
  assertEquals(softMin, item.getSoftMinimum());
  assertEquals(softMax, item.getSoftMaximum());
  assertEquals(stepSize, item.getStepSize());
  assertEquals(choices, item.getChoices());
}
org.scijava.moduleModuleItemgetDefaultValue

Javadoc

Gets the default value.

Popular methods of ModuleItem

  • getName
  • getType
    Gets the type of the item.
  • getWidgetStyle
    Gets the preferred widget style to use when rendering the item in a user interface.
  • getValue
    Gets the item's current value with respect to the given module.
  • isRequired
    Gets whether the item value must be specified (i.e., no default).
  • getColumnCount
    Gets the preferred width of the input field in characters (if applicable).
  • getGenericType
    Gets the type of the item, including Java generic parameters. For many modules, this may be the same
  • getLabel
  • getVisibility
    Gets the visibility of the item.
  • setValue
    Sets the item's current value with respect to the given module.
  • get
  • getChoices
    Gets the list of possible values.
  • get,
  • getChoices,
  • getDescription,
  • getIOType,
  • getMaximumValue,
  • getMinimumValue,
  • getPersistKey,
  • getSoftMaximum,
  • getSoftMinimum

Popular in Java

  • Making http requests using okhttp
  • getSystemService (Context)
  • findViewById (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Top PhpStorm plugins
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