fj.data.Option.fromNull()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中fj.data.Option.fromNull()方法的一些代码示例,展示了Option.fromNull()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.fromNull()方法的具体详情如下:
包路径:fj.data.Option
类名称:Option
方法名:fromNull

Option.fromNull介绍

[英]Turns an unsafe nullable value into a safe optional value. If t == null then return none, otherwise, return the given value in some.
[中]将不安全的可空值转换为安全的可选值。如果t == null,则返回none,否则,返回给定的值。

代码示例

代码示例来源:origin: no.arktekk.unix/unix-common

public FileAttributes mode( UnixFileMode mode )
{
  return new FileAttributes( user, group, fromNull( mode ), tags );
}

代码示例来源:origin: no.arktekk.unix/unix-common

public PackageParameters contact( String contact )
{
  return contact( fromNull( contact ) );
}

代码示例来源:origin: no.arktekk.unix/unix-common

public PackageParameters contactEmail( String contactEmail )
{
  return contactEmail( fromNull( contactEmail ) );
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns a potential value that the given key maps to.
 *
 * @param k The key to look up in the hash map.
 * @return A potential value for the given key.
 */
public Option<V> get(final K k) {
 return fromNull(m.get(new Key(k)));
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Deletes the entry in the hash map that corresponds to the given key and returns any associated value.
 *
 * @param k The key to delete from this hash map.
 * @return The value that was associated with the given key, if there was one.
 */
public Option<V> getDelete(final K k) {
 return fromNull(m.remove(new Key(k)));
}

代码示例来源:origin: no.arktekk.unix/unix-common

public PackageParameters license( String license )
{
  return license( fromNull( license ) );
}

代码示例来源:origin: no.arktekk.unix/unix-common

public FileAttributes group( String group )
{
  return new FileAttributes( user, fromNull( group ), mode, tags );
}

代码示例来源:origin: no.arktekk.unix/unix-common

public PackageParameters description( String description )
{
  return description( fromNull( description ) );
}

代码示例来源:origin: no.arktekk.unix/unix-common

public PackageParameters architecture( String architecture )
{
  return architecture( fromNull( architecture ) );
}

代码示例来源:origin: no.arktekk.unix/unix-common

public FileAttributes user( String user )
{
  return new FileAttributes( fromNull( user ), group, mode, tags );
}

代码示例来源:origin: org.esupportail/esup-opi-utils

private LdapAttributes(
    String uidAttribute,
    String displayNameAttribute,
    String emailAttribute,
    String cnAttribute,
    String nomUsuelAttribute,
    String prenomAttribute,
    String eduPersonPrincipalNameAttribute,
    String filterPers) {
  this.uidAttribute = fromNull(uidAttribute).valueE("uidAttribute is null !");
  this.displayNameAttribute = fromNull(displayNameAttribute).valueE("displayNameAttribute is null !");
  this.emailAttribute = fromNull(emailAttribute).valueE("emailAttribute us null !");
  this.cnAttribute = fromNull(cnAttribute).valueE("cnAttribute is null !");
  this.nomUsuelAttribute = fromNull(nomUsuelAttribute).valueE("nomUsuelAttribute is null !");
  this.prenomAttribute = fromNull(prenomAttribute).valueE("prenomAttribute is null !");
  this.eduPersonPrincipalNameAttribute =
      fromNull(eduPersonPrincipalNameAttribute).valueE("eduPersonPrincipalName is null !");
  this.filterPers = fromNull(filterPers).valueE("filterPers is null !");
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns the first non-<code>null</code> value in the given list of optional values. If none is found return the given default value.
 *
 * @param values The potentially <code>null</code> values to search.
 * @param def The default value if no value is found in the list.
 * @return The first non-<code>null</code> value in the given list of optional values. If none is found return the given default value.
 */
public static <X> X nullablefindFirst(final List<X> values, final F0<X> def) {
 return findFirst(values.map(Option.fromNull()), def);
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns an optional non-empty string, or no value if the given string is empty.
 *
 * @param s A string to turn into an optional non-empty string.
 * @return an optional non-empty string, or no value if the given string is empty.
 */
public static Option<String> fromString(final String s) {
 return fromNull(s).bind(s1 -> {
  final Option<String> none = none();
  return s.length() == 0 ? none : some(s);
 });
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns the first non-<code>null</code> value found in the list of visitors after application of the given value,
 * otherwise returns the given default.
 *
 * @param visitors The list of visitors to apply looking for a non-<code>null</code>.
 * @param def The default if none of the visitors yield a non-<code>null</code> value.
 * @param value The value to apply to the visitors.
 * @return The first value found in the list of visitors after application of the given value, otherwise returns the
 * given default.
 */
public static <A, B> B nullableVisitor(final List<F<A, B>> visitors, final F0<B> def, final A value) {
 return visitor(visitors.map(k -> compose(Option.fromNull(), k)), def, value);
}

代码示例来源:origin: org.esupportail/esup-opi-web-beans

String str1 = fromNull(p1).map(toStr).some();
String str2 = fromNull(p2).map(toStr).some();
return sortStr(str1, str2);

代码示例来源:origin: org.esupportail/esup-opi-web-beans

public IndividuPojo() {
  individu = new Individu();
  doNotHaveCodeNne = false;
  isManager = false;
  etat = fromNull(individu.getState())
      .map(new F<String, EtatIndividu>() {
        public EtatIndividu f(String s) {
          return EtatIndividu.fromString(s);
        }
      }).toNull();
  dateCreationDossier = null;
  isUsingLC = false;
  isUsingDEF = false;
  isUsingSearch = false;
}

代码示例来源:origin: no.arktekk.unix/unix-core

public static UnixFsObject.RegularFile fromFileObject( RelativePath toFile, FileObject fromFile,
                            FileAttributes attributes )
  throws FileSystemException
{
  FileContent content = fromFile.getContent();
  LocalDateTime time = new LocalDateTime( content.getLastModifiedTime() );
  return regularFile( toFile, time, content.getSize(), fromNull( attributes ) );
}

代码示例来源:origin: org.esupportail/esup-opi-web-beans

@Override
  public String f(final IndVoeuPojo ip) {
    final String libWebVet = fromNull(ip.getVrsEtape())
        .map(new F<org.esupportail.wssi.services.remote.VersionEtapeDTO, String>() {
          @Override
          public String f(final 
              org.esupportail.wssi.services.remote.VersionEtapeDTO v) {
            return fromString(v.getLibWebVet()).map(new F<String, String>() {
              @Override
              public String f(final String l) {
                return l.trim();
              }
              
            }).orSome("");
          }
        }).orSome("");
    final String libAvis = fromNull(ip.getAvisEnService()).map(new F<Avis, String>() {
      @Override
      public String f(final Avis a) {
        return fromNull(a.getResult()).map(new F<TypeDecision, String>() {
          @Override
          public String f(final TypeDecision td) {
            return td.getLibelle();
          }
        }).orSome("");
      }
    }).orSome("");
    return libWebVet + libAvis;
  }
};

代码示例来源:origin: org.esupportail/esup-opi-web-beans

doNotHaveCodeNne = false;
regimeInscription = ri;
etat = fromNull(individu.getState())
    .map(new F<String, EtatIndividu>() {
      public EtatIndividu f(String s) {
isUsingDEF = false;
isUsingSearch = false;
etatIndBac = fromNull(individu.getIndBac())
    .filter(new F<Set<IndBac>, Boolean>() {
      public Boolean f(Set<IndBac> indBacs) {

代码示例来源:origin: org.esupportail/esup-opi-web-beans

/**
 * @deprecated Should not be used anymore
 */
public IndividuPojo(final Individu individu,
          final DomainApoService apoServ,
          final ParameterService parameterService,
          final Set<Commission> commissions,
          final Set<TypeDecision> typeDecisions,
          final List<CalendarRDV> listCalendrierParam,
          final Set<VersionEtapeDTO> versionsEtape) {
  this.individu = individu;
  doNotHaveCodeNne = false;
  etat = fromNull(individu.getState())
      .map(new F<String, EtatIndividu>() {
        public EtatIndividu f(String s) {
          return EtatIndividu.fromString(s);
        }
      }).toNull();
  initIndVoeuPojo(apoServ, parameterService, commissions, typeDecisions, listCalendrierParam, versionsEtape);
  isManager = false;
  dateCreationDossier = individu.getDateCreaEnr();
  isUsingLC = false;
  isUsingDEF = false;
  isUsingSearch = false;
}

相关文章