Example usage for org.apache.commons.lang3.mutable MutableBoolean setValue

List of usage examples for org.apache.commons.lang3.mutable MutableBoolean setValue

Introduction

In this page you can find the example usage for org.apache.commons.lang3.mutable MutableBoolean setValue.

Prototype

@Override
public void setValue(final Boolean value) 

Source Link

Document

Sets the value from any Boolean instance.

Usage

From source file:asterix.parser.classad.TokenValue.java

public void getBoolValue(MutableBoolean b) {
    b.setValue(boolValue);
}

From source file:bwem.MapDrawer.java

private boolean processCommandVariants(String command, String attributName, MutableBoolean attribut) {
    if (command.equals("show " + attributName)) {
        attribut.setTrue();//from   ww w  . j  a v  a  2  s.c om
        return true;
    }
    if (command.equals("hide " + attributName)) {
        attribut.setFalse();
        return true;
    }
    if (command.equals(attributName)) {
        attribut.setValue(!attribut.booleanValue());
        return true;
    }
    return false;
}

From source file:asterix.parser.classad.FunctionCall.java

public boolean privateEvaluate(EvalState state, Value value, ExprTreeHolder tree) throws HyracksDataException {
    FunctionCall tmpSig = new FunctionCall();
    Value tmpVal = new Value();
    ExprTreeHolder argSig = new ExprTreeHolder();
    MutableBoolean rval = new MutableBoolean();
    if (!privateEvaluate(state, value)) {
        return false;
    }//from  w w  w  . j a  v  a2 s .co  m
    tmpSig.functionName = functionName;
    rval.setValue(true);
    for (ExprTree i : arguments.getExprList()) {
        rval.setValue(i.publicEvaluate(state, tmpVal, argSig));
        if (rval.booleanValue())
            tmpSig.arguments.add(argSig.getInnerTree());
    }
    tree.setInnerTree(tmpSig);
    return rval.booleanValue();
}

From source file:info.magnolia.ui.api.location.LocationControllerTest.java

@Test
public void testGoToWithCancelledWarning() {

    // GIVEN/*  www .  ja v  a  2  s .  c  o m*/
    LocationChangeRequestedHandler requestHandler = new LocationChangeRequestedHandlerThatWarns();
    LocationChangedHandler changeHandler = new LocationChangedHandler();

    SimpleEventBus eventBus = new SimpleEventBus();
    eventBus.addHandler(LocationChangeRequestedEvent.class, requestHandler);
    eventBus.addHandler(LocationChangedEvent.class, changeHandler);

    final MutableBoolean shellCalledToConfirm = new MutableBoolean(false);

    Shell shell = mock(Shell.class);
    doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            shellCalledToConfirm.setValue(true);
            ConfirmationHandler o = (ConfirmationHandler) invocation.getArguments()[1];
            o.onCancel();
            return null;
        }
    }).when(shell).askForConfirmation(anyString(), any(ConfirmationHandler.class));

    LocationController locationController = new LocationController(eventBus, shell);

    assertEquals(Location.NOWHERE, locationController.getWhere());

    Location newLocation = getNewEmptyLocation();

    // WHEN
    locationController.goTo(newLocation);

    // THEN
    assertTrue(shellCalledToConfirm.booleanValue());

    assertEquals(Location.NOWHERE, locationController.getWhere());

    assertNotNull(requestHandler.event);
    assertSame(newLocation, requestHandler.event.getNewLocation());

    assertNull(changeHandler.event);
}

From source file:info.magnolia.ui.api.location.LocationControllerTest.java

@Test
public void testGoToWithConfirmedWarning() {

    // GIVEN//w  w w.  j  a v a2 s .  com
    LocationChangeRequestedHandler requestHandler = new LocationChangeRequestedHandlerThatWarns();
    LocationChangedHandler changeHandler = new LocationChangedHandler();

    SimpleEventBus eventBus = new SimpleEventBus();
    eventBus.addHandler(LocationChangeRequestedEvent.class, requestHandler);
    eventBus.addHandler(LocationChangedEvent.class, changeHandler);

    final MutableBoolean shellCalledToConfirm = new MutableBoolean(false);

    Shell shell = mock(Shell.class);
    doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            shellCalledToConfirm.setValue(true);
            ConfirmationHandler o = (ConfirmationHandler) invocation.getArguments()[1];
            o.onConfirm();
            return null;
        }
    }).when(shell).askForConfirmation(anyString(), any(ConfirmationHandler.class));

    LocationController locationController = new LocationController(eventBus, shell);

    assertEquals(Location.NOWHERE, locationController.getWhere());

    Location newLocation = getNewEmptyLocation();

    // WHEN
    locationController.goTo(newLocation);

    // THEN
    assertTrue(shellCalledToConfirm.booleanValue());

    assertSame(newLocation, locationController.getWhere());

    assertNotNull(requestHandler.event);
    assertSame(newLocation, requestHandler.event.getNewLocation());

    assertNotNull(changeHandler.event);
    assertSame(newLocation, changeHandler.event.getNewLocation());
}

From source file:asterix.parser.classad.AttributeReference.java

public void getComponents(ExprTreeHolder tree, AMutableCharArrayString attr, MutableBoolean abs)
        throws HyracksDataException {
    tree.copyFrom(expr);//from www . j  a  v a 2s  .c  o m
    attr.setValue(attributeStr);
    abs.setValue(absolute);
}

From source file:asterix.parser.classad.AttributeReference.java

public boolean privateEvaluate(EvalState state, Value val, ExprTreeHolder sig) throws HyracksDataException {
    ExprTreeHolder tree = new ExprTreeHolder();
    ExprTreeHolder exprSig = new ExprTreeHolder();
    ClassAd curAd = new ClassAd(state.getCurAd());
    MutableBoolean rval = new MutableBoolean(true);
    switch (findExpr(state, tree, exprSig, true)) {
    case EVAL_FAIL:
        rval.setValue(false);
        break;//from w  ww.j ava 2  s . c o  m
    case EVAL_ERROR:
        val.setErrorValue();
        break;
    case EVAL_UNDEF:
        val.setUndefinedValue();
        break;
    case EVAL_OK: {
        if (state.getDepthRemaining() <= 0) {
            val.setErrorValue();
            state.getCurAd().setValue(curAd);
            return false;
        }
        state.decrementDepth();
        rval.setValue(tree.publicEvaluate(state, val));
        state.incrementDepth();
        break;
    }
    default:
        throw new HyracksDataException("ClassAd:  Should not reach here");
    }
    sig.setInnerTree((new AttributeReference(exprSig, attributeStr, absolute)));
    state.getCurAd().setValue(curAd);
    return rval.booleanValue();
}

From source file:com.datatorrent.lib.appdata.query.SimpleDoneQueryQueueManagerTest.java

@Test
public void simpleExpireBlockThenUnblock() throws Exception {
    SimpleDoneQueueManager<Query, Void> sdqqm = new SimpleDoneQueueManager<Query, Void>();

    sdqqm.setup(null);/*  w w  w  .  j av a2s  .  c o m*/
    sdqqm.beginWindow(0);

    Query query = new MockQuery("1");
    MutableBoolean expire = new MutableBoolean(false);
    sdqqm.enqueue(query, null, expire);

    sdqqm.endWindow();
    sdqqm.beginWindow(1);

    //Expire
    expire.setValue(true);

    ExceptionSaverExceptionHandler eseh = new ExceptionSaverExceptionHandler();
    testBlockingNoStop(sdqqm, eseh);

    query = new MockQuery("2");
    sdqqm.enqueue(query, null, new MutableBoolean(false));

    Thread.sleep(1000);

    Assert.assertNull(eseh.getCaughtThrowable());

    sdqqm.endWindow();
    sdqqm.teardown();
}

From source file:fr.duminy.components.swing.listpanel.SimpleItemManagerTest.java

@Test
public void testCreateItemCallsInitItem() {
    final SimpleItemManager.FormDisplayer displayer = mock(SimpleItemManager.FormDisplayer.class);
    final FormBuilder<Bean> builder = new DefaultFormBuilder<>(Bean.class);
    final MutableBoolean called = new MutableBoolean(false);

    GuiActionRunner.execute(new GuiQuery<Void>() {
        protected Void executeInEDT() {
            final SimpleItemManager manager = new SimpleItemManager<Bean>(Bean.class, builder, new JLabel(""),
                    title, displayer) {/*from w w w .  jav  a  2s . co  m*/
                @Override
                protected void initItem(Bean item) {
                    called.setValue(true);
                }
            };

            manager.createItem();
            return null;
        }
    });

    assertThat(called.getValue()).as("initItem called").isTrue();
}

From source file:fr.duminy.jbackup.core.JBackupImplTest.java

private <T extends Callable<Void>> T createAlwaysWaitingTask(final Class<T> taskClass,
        final MutableBoolean taskStarted) throws Exception {
    final T mockTask = mock(taskClass);
    when(mockTask.call()).then(new Answer<Object>() {
        @Override/*from   w w  w .j av a 2  s.c  om*/
        public Object answer(InvocationOnMock invocation) throws Throwable {
            taskStarted.setValue(true);
            while (true) {
                Thread.sleep(100);
            }
        }
    });
    return mockTask;
}