当前位置: 首页>>代码示例>>Java>>正文


Java Option.none方法代码示例

本文整理汇总了Java中fj.data.Option.none方法的典型用法代码示例。如果您正苦于以下问题:Java Option.none方法的具体用法?Java Option.none怎么用?Java Option.none使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fj.data.Option的用法示例。


在下文中一共展示了Option.none方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sumBatchResult

import fj.data.Option; //导入方法依赖的package包/类
private static Option<Integer> sumBatchResult(int[] xs)
{
    int result = 0;
    for (int x: xs)
    {
        if (x >= 0)
        {
            result += x;
        }
        else if (x == Statement.SUCCESS_NO_INFO)
        {
            return Option.none();
        }
        else if (x == Statement.EXECUTE_FAILED)
        {
            throw new IllegalStateException("a batch command failed but an sql exception was not raised by the driver!");
        }
        else
        {
            throw new IllegalStateException("unrecognized batch return code " + x);
        }
    }
    return Option.some(result);
}
 
开发者ID:novarto-oss,项目名称:sane-dbc,代码行数:25,代码来源:Binders.java

示例2: run

import fj.data.Option; //导入方法依赖的package包/类
@Override
public Option<Integer> run(Connection c) throws SQLException
{
    if (Collections.isEmpty(as))
    {
        return Option.none();
    }

    if (!isInsert(sql))
    {
        throwIfAutoCommit(c);
    }
    try (PreparedStatement preparedStatement = c.prepareStatement(sql))
    {

        return binder.f(preparedStatement);
    }
}
 
开发者ID:novarto-oss,项目名称:sane-dbc,代码行数:19,代码来源:BatchUpdateOp.java

示例3: getAttachNode

import fj.data.Option; //导入方法依赖的package包/类
private Option<KnotNode> getAttachNode( final PullerNode pullerNode ) {
    List<KnotNode> knots = pullerNode.color == BLUE ? blueKnots : redKnots;
    List<KnotNode> free = knots.filter( _free ).filter( new F<KnotNode, Boolean>() {
        @Override public Boolean f( final KnotNode knotNode ) {
            return knotPullerDistance( knotNode, pullerNode ) < 80;
        }
    } );
    if ( free.length() > 0 ) {
        KnotNode closest = free.minimum( FJUtils.ord( new F<KnotNode, Double>() {
            @Override public Double f( final KnotNode k ) {
                return knotPullerDistance( k, pullerNode );
            }
        } ) );
        return Option.some( closest );
    }
    else { return Option.none(); }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:TugOfWarCanvas.java

示例4: getToolbarOffset

import fj.data.Option; //导入方法依赖的package包/类
private static double getToolbarOffset( final int levelIndex, final BuildAFractionModel model, final SceneContext context, final BooleanProperty soundEnabled, boolean fractionLab, final boolean showContainerNodeOnStartup ) {
    ShapeSceneNode node = new ShapeSceneNode( levelIndex, model, context, soundEnabled, Option.<Double>none(), fractionLab, showContainerNodeOnStartup );

    //Re-layout the toolbox based on the location of the title
    double desiredToolboxCenter = node.title.getFullBounds().getCenterX();
    double originalToolboxCenter = node.toolboxNode.getFullBounds().getCenterX();
    double delta = desiredToolboxCenter - originalToolboxCenter;

    //make sure it doesn't go off the screen to the left
    double originalToolboxX = node.toolboxNode.getFullBounds().getX();
    final double newToolboxX = originalToolboxX + delta;
    if ( newToolboxX < INSET ) {
        delta = INSET - originalToolboxX;
    }
    return delta;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:ShapeSceneNode.java

示例5: pick

import fj.data.Option; //导入方法依赖的package包/类
@Override protected Option<PickResult> pick( final Vector2D vector2D, final MockState mockState ) {
    for ( SNode sNode : children.reverse() ) {
        final Option<PickResult> picked = sNode.pick( vector2D, mockState );
        if ( picked.isSome() ) {
            return picked;
        }
    }
    return Option.none();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:SList.java

示例6: getFrontCardInStack

import fj.data.Option; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") private Option<T> getFrontCardInStack() {
    List<T> sorted = cards.sort( FJUtils.ord( new F<T, Double>() {
        @Override public Double f( final T n ) {
            final Option<Integer> positionInStack = n.getPositionInStack(); //unchecked warning
            return positionInStack.orSome( -1 ).doubleValue();
        }
    } ) );
    return sorted.isEmpty() ? Option.<T>none() : Option.some( sorted.last() );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:Stack.java

示例7: undo

import fj.data.Option; //导入方法依赖的package包/类
void undo() {
    setDragRegionPickable( true );
    Option<Fraction> value = isComplete() ? Option.some( getValue() ) : Option.<Fraction>none();

    Point2D topCardLocation = numerator.cardNode != null ? numerator.cardNode.getGlobalTranslation() : null;
    Point2D bottomCardLocation = denominator.cardNode != null ? denominator.cardNode.getGlobalTranslation() : null;
    Point2D wholeCardLocation = whole.cardNode != null ? whole.cardNode.getGlobalTranslation() : null;

    if ( cardNode != null ) {
        cardNode.undo();
        cardNode = null;
    }

    //Undo whichever happened last
    if ( dropListHistory.length() > 0 ) {
        FractionNodePosition element = dropListHistory.last();
        if ( element == FractionNodePosition.WHOLE ) { undo( whole, wholeCardLocation ); }
        else if ( element == FractionNodePosition.NUMERATOR ) { undo( numerator, topCardLocation ); }
        else if ( element == FractionNodePosition.DENOMINATOR ) { undo( denominator, bottomCardLocation ); }

        //Drop the last item
        dropListHistory = dropListHistory.reverse().drop( 1 ).reverse();
    }
    undoButton.setVisible( numerator.cardNode != null || denominator.cardNode != null || whole.cardNode != null );
    for ( VoidFunction1<Option<Fraction>> undoListener : undoListeners ) {
        undoListener.apply( value );
    }

    context.updateStacks();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:FractionNode.java

示例8: toUserInput

import fj.data.Option; //导入方法依赖的package包/类
private UserInput toUserInput() {
    if ( mousePressed.size() > 0 ) {
        return new UserInput( Option.some( mousePressed.get( mousePressed.size() - 1 ) ) );
    }
    else {
        return new UserInput( Option.<Vector2D>none() );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:EventRecorder.java

示例9: parseName

import fj.data.Option; //导入方法依赖的package包/类
public static Option<NameValue> parseName(String value) {
  return !value.trim().isEmpty()
      && !value.endsWith(" ")
      && !value.startsWith(" ")
      && value.length() <= 120

      ? some(NameValue0(value))
      : Option.<NameValue>none();
}
 
开发者ID:jbgi,项目名称:eventsrc4j,代码行数:10,代码来源:PersonName.java

示例10: add

import fj.data.Option; //导入方法依赖的package包/类
public <T extends A> SkinnyMux<A> add(Class<T> c, String name, JsonEncoder<T> encoder) {
    F<A, Option<JsonValue>> f =
      a ->
        c.isInstance(a) ?
        Option.some(jObj(p(name, encoder.encode(c.cast(a))))) :
        Option.none();

    return new SkinnyMux<>(a -> encoders.f(a).orElse(f.f(a)));
}
 
开发者ID:kantega,项目名称:kson,代码行数:10,代码来源:SkinnyMux.java

示例11: pick

import fj.data.Option; //导入方法依赖的package包/类
@Override protected Option<PickResult> pick( final Vector2D vector2D, final MockState mockState ) {
    return shape.contains( vector2D.x, vector2D.y ) ? Option.some( new PickResult( this, mockState.getDragHandler() ) ) : Option.<PickResult>none();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:FillShape.java

示例12: pick

import fj.data.Option; //导入方法依赖的package包/类
@Override protected Option<PickResult> pick( final Vector2D vector2D, final MockState mockState ) {
    return toTextLayout.f( new Args( mockState.getFont(), text, mockState.getFontRenderContext() ) ).
            getOutline( new AffineTransform() ).contains( vector2D.toPoint2D() ) ? Option.some( new PickResult( this, mockState.getDragHandler() ) ) : Option.<PickResult>none();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:5,代码来源:DrawText.java

示例13: pick

import fj.data.Option; //导入方法依赖的package包/类
@Override protected Option<PickResult> pick( final Vector2D vector2D, final MockState mockState ) {
    return Option.none();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:DrawShape.java

示例14: ForceArrowNode

import fj.data.Option; //导入方法依赖的package包/类
public ForceArrowNode( final boolean transparent, final Vector2D tail, final double forceInNewtons, final String name, Color color, final TextLocation textLocation, final boolean showValues ) {
    this( transparent, tail, forceInNewtons, name, color, textLocation, showValues, Option.<ForceArrowNode>none() );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:ForceArrowNode.java

示例15: newLevel

import fj.data.Option; //导入方法依赖的package包/类
public static MatchingGameState newLevel( int level, List<GameResult> gameResults, AbstractLevelFactory factory ) {
    final List<Cell> startCells = createCells( 100, 427, 130, 120, 6, 2, 0, 0 );
    final List<Cell> scoreCells = createCells( 10, 12, 155, 90, 6, 1, 10, 0 );
    return new MatchingGameState( factory.createLevel( level, startCells ), startCells, scoreCells, 0, 0, 0, new GameInfo( level, false, 0, Mode.USER_IS_MOVING_OBJECTS_TO_THE_SCALES, 0, 0, 0, true ), 0, gameResults, Option.<Answer>none(), levelCount++ );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:6,代码来源:MatchingGameState.java


注:本文中的fj.data.Option.none方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。