All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.packagesettings.Field Maven / Gradle / Ivy

There is a newer version: 24.9.0
Show newest version
package org.packagesettings;

import org.lambda.functions.Function0;

import java.util.Map;

public class Field
{
  public final String   Name;
  public final Class Class;
  public Field(String name, Class clazz)
  {
    this.Name = name;
    this.Class = clazz;
  }
  public boolean isPresent(Map settings)
  {
    Settings value = settings.get(Name);
    return value != null && this.Class.isInstance(value.getValue());
  }
  public T getValue(Map settings, Function0 defaultValue)
  {
    return isPresent(settings) ? (T) settings.get(Name).getValue() : defaultValue.call();
  }
  public String getFieldName()
  {
    return Name;
  }
  public Class getFieldClass()
  {
    return Class;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy