本文整理了Java中fj.data.Option.orSome()
方法的一些代码示例,展示了Option.orSome()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.orSome()
方法的具体详情如下:
包路径:fj.data.Option
类名称:Option
方法名:orSome
[英]Returns the value of this optional value or the given argument.
[中]返回此可选值或给定参数的值。
代码示例来源:origin: com.stratio.mojo.unix/unix-rpm
private String rpmbuild()
{
return rpmbuild.orSome( "rpmbuild" );
}
}
代码示例来源:origin: com.stratio.mojo.unix/unix-sysv-pkg
protected String toString( FileAttributes attributes )
{
return attributes.mode.map( showOcalString ).orSome( "?" ) + " " +
attributes.user.orSome( "?" ) + " " +
attributes.group.orSome( "?" );
}
}
代码示例来源:origin: com.stratio.mojo.unix/unix-sysv-pkg
protected PrototypeEntry( Option<String> pkgClass, Option<Boolean> relative, U object )
{
Validate.validateNotNull( pkgClass, relative, object );
this.pkgClass = pkgClass.orSome( "none" );
this.relative = relative;
this.object = object;
}
代码示例来源:origin: no.arktekk.unix/unix-sysv-pkg
protected PrototypeEntry( Option<String> pkgClass, Option<Boolean> relative, U object )
{
Validate.validateNotNull( pkgClass, relative, object );
this.pkgClass = pkgClass.orSome( "none" );
this.relative = relative;
this.object = object;
}
代码示例来源:origin: org.codehaus.mojo.unix/unix-pkg
public String getPath()
{
if ( TRUE.equals( relative.orSome( false ) ) )
{
return object.path.string;
}
return object.path.asAbsolutePath( "/" );
}
代码示例来源:origin: com.stratio.mojo.unix/unix-sysv-pkg
public String getPath()
{
if ( TRUE.equals( relative.orSome( false ) ) )
{
return object.path.string;
}
return object.path.asAbsolutePath( "/" );
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Uses an association list to perform a lookup with equality and returns a function that can be applied to a default,
* followed by the associated key to return a value.
*
* @param x The association list.
* @param eq The equality for the association list keys.
* @return A function that can be applied to a default value (there is no association) and an associated key.
*/
public static <A, B> F<P1<B>, F<A, B>> associationLazy(final List<P2<A, B>> x, final Equal<A> eq) {
return curry((def, a) -> lookup(eq, x, a).orSome(def));
}
}
代码示例来源:origin: org.codehaus.mojo.unix/unix-pkg
protected String getProcessedPath( Option<File> realPath )
{
return realPath.map( new F<File, String>()
{
public String f( File file )
{
return getPath() + "=" + file.getAbsolutePath();
}
} ).orSome( getPath() );
}
代码示例来源:origin: no.arktekk.unix/unix-sysv-pkg
protected String getProcessedPath( Option<File> realPath )
{
return realPath.map( new F<File, String>()
{
public String f( File file )
{
return getPath() + "=" + file.getAbsolutePath();
}
} ).orSome( getPath() );
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Returns the first value available in the given list of optional values. If none is found return the given default value.
*
* @param values The optional values to search.
* @param def The default value if no value is found in the list.
* @return The first value available in the given list of optional values. If none is found return the given default value.
*/
public static <X> X findFirst(final List<Option<X>> values, final F0<X> def) {
return Monoid.<X>firstOptionMonoid().sumLeft(values).orSome(def);
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Uses an association list to perform a lookup with equality and returns a function that can be applied to a default,
* followed by the associated key to return a value.
*
* @param x The association list.
* @param eq The equality for the association list keys.
* @return A function that can be applied to a default value (there is no association) and an associated key.
*/
public static <A, B> F<B, F<A, B>> association(final List<P2<A, B>> x, final Equal<A> eq) {
return curry((def, a) -> lookup(eq, x, a).orSome(def));
}
代码示例来源:origin: com.stratio.mojo.unix/unix-sysv-pkg
protected String getProcessedPath( Option<File> realPath )
{
return realPath.map( new F<File, String>()
{
public String f( File file )
{
return getPath() + "=" + file.getAbsolutePath();
}
} ).orSome( getPath() );
}
代码示例来源:origin: org.functionaljava/functionaljava
@Override
public <M> F<S, M> foldMap(final Monoid<M> monoid, final F<A, M> f) {
return s -> getOption(s).map(f).orSome(monoid.zero());
}
代码示例来源:origin: org.functionaljava/functionaljava
@Override
public <M> F<S, M> foldMap(final Monoid<M> m, final F<A, M> f) {
return s -> POptional.this.getOption(s).map(f).orSome(m.zero());
}
};
代码示例来源:origin: org.functionaljava/functionaljava
public final <B> Set<Option<B>> traverseSet(Ord<B> ord, F<A, Set<B>> f) {
Ord<Option<B>> optOrd = Ord.optionOrd(ord);
return map(a -> f.f(a).map(optOrd, Option::some)).orSome(Set.empty(optOrd));
}
代码示例来源:origin: org.functionaljava/functionaljava
/**
* Returns a stream that is either infinite or bounded up to the maximum value of the given iterator starting at the
* given value and stepping at the given increment.
*
* @param e The enumerator to compute successors from.
* @param from The value to begin computing successors from.
* @param step The increment to step.
* @return A stream that is either infinite or bounded up to the maximum value of the given iterator starting at the
* given value and stepping at the given increment.
*/
public static <A> Stream<A> forever(final Enumerator<A> e, final A from, final long step) {
return cons(from, () -> e.plus(from, step).map(a -> forever(e, a, step)).orSome(Stream.nil()));
}
代码示例来源:origin: no.arktekk.unix/unix-sysv-pkg
public void streamTo( LineStreamWriter stream )
{
stream.
add( "Pathname: " + pathname ).
add( "Type: " + type ).
add( "Expected file size (bytes): " + fileSize ).
add( "Expected sum(1) of contents: " + sum ).
add( "Expected last modification: " + lastModification.map( formatter ).orSome( "not set" ) );
}
};
代码示例来源:origin: org.codehaus.mojo.unix/unix-pkg
public void streamTo( LineStreamWriter stream )
{
stream.
add( "Pathname: " + pathname ).
add( "Type: " + type ).
add( "Expected file size (bytes): " + fileSize ).
add( "Expected sum(1) of contents: " + sum ).
add( "Expected last modification: " + lastModification.map( formatter ).orSome( "not set" ) );
}
};
代码示例来源:origin: com.stratio.mojo.unix/unix-sysv-pkg
public void streamTo( LineStreamWriter stream )
{
stream.
add( "Pathname: " + pathname ).
add( "Type: " + type ).
add( "Expected file size (bytes): " + fileSize ).
add( "Expected sum(1) of contents: " + sum ).
add( "Expected last modification: " + lastModification.map( formatter ).orSome( "not set" ) );
}
};
代码示例来源:origin: no.arktekk.unix/unix-sysv-pkg
public PkginfoFile f( PkginfoFile pkginfoFile )
{
return pkginfoFile.
pstamp( map2.get( "PSTAMP" ) ).
desc( map2.get( "DESC" ) ).
email( map2.get( "EMAIL" ) ).
classes( map2.get( "CLASSES" ).map( flip( StringF.split ).f( "," ) ).orSome( List.<String>nil() ) );
}
} );
内容来源于网络,如有侵权,请联系作者删除!