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

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

Introduction

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

Prototype

public void setFalse() 

Source Link

Document

Sets the value to true.

Usage

From source file:bwem.MapDrawer.java

private boolean processCommandVariants(String command, String attributName, MutableBoolean attribut) {
    if (command.equals("show " + attributName)) {
        attribut.setTrue();/*w  w  w.j  av a2  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:de.uni_potsdam.hpi.asg.logictool.helper.BDDHelper.java

public static boolean evaluateBDD(MutableBoolean result, BDD bdd, State state, Netlist netlist) {
    if (bdd == null) {
        return false;
    }/*from   w  ww .  j a  va  2 s .  com*/
    BDD bdd2 = bdd.and(bdd.getFactory().one());
    for (Entry<Signal, Value> entry : state.getStateValues().entrySet()) {
        BDD sigbdd = null;
        switch (entry.getValue()) {
        case falling:
        case high:
            sigbdd = netlist.getNetlistVariableBySignal(entry.getKey()).toBDD();
            break;
        case low:
        case rising:
            sigbdd = netlist.getNetlistVariableBySignal(entry.getKey()).toNotBDD();
            break;
        }
        bdd2 = bdd2.restrictWith(sigbdd);
    }
    for (Entry<NetlistVariable, Boolean> entry : netlist.getQuasiSignals().entrySet()) {
        BDD sigbdd = null;
        if (entry.getValue()) {
            //true => Normally 1
            sigbdd = entry.getKey().toBDD();
        } else {
            sigbdd = entry.getKey().toNotBDD();
        }
        bdd2 = bdd2.restrictWith(sigbdd);
    }

    if (bdd2.isOne()) {
        result.setTrue();
    } else if (bdd2.isZero()) {
        result.setFalse();
    } else {
        System.out.println(BDDHelper.getFunctionString(bdd2, netlist));
        logger.error("BDD not restricted enough?!");

        return false;
    }
    return true;
}

From source file:de.uni_potsdam.hpi.asg.logictool.mapping.SequenceBasedAndGateDecomposer.java

private boolean evaluateBDD(MutableBoolean result, BDD bdd, State state) {
    BDD bdd2 = bdd.and(factory.one());//from  w  w  w. j  a  v  a2 s . c  o  m
    for (Entry<Signal, Value> entry : state.getStateValues().entrySet()) {
        BDD sigbdd = null;
        switch (entry.getValue()) {
        case falling:
        case high:
            sigbdd = getPosBDD(entry.getKey());
            break;
        case low:
        case rising:
            sigbdd = getNegBDD(entry.getKey());
            break;
        }
        bdd2 = bdd2.restrictWith(sigbdd);
    }
    for (Entry<NetlistVariable, Boolean> entry : netlist.getQuasiSignals().entrySet()) {
        BDD sigbdd = null;
        if (entry.getValue()) {
            //true => Normally 1
            sigbdd = getPosBDD(quasimap.get(entry.getKey()));
        } else {
            sigbdd = getNegBDD(quasimap.get(entry.getKey()));
        }
        bdd2 = bdd2.restrictWith(sigbdd);
    }

    if (bdd2.isOne()) {
        result.setTrue();
    } else if (bdd2.isZero()) {
        result.setFalse();
    } else {
        System.out.println(BDDHelper.getFunctionString(bdd2, netlist));
        logger.error("BDD not restricted enough?!");

        return false;
    }
    return true;
}

From source file:forge.game.card.Card.java

@Override
public final boolean canBeTargetedBy(final SpellAbility sa) {
    if (sa == null) {
        return true;
    }/*  ww  w. j a v  a 2 s. c  om*/

    // CantTarget static abilities
    for (final Card ca : getGame().getCardsIn(ZoneType.listValueOf("Battlefield,Command"))) {
        final Iterable<StaticAbility> staticAbilities = ca.getStaticAbilities();
        for (final StaticAbility stAb : staticAbilities) {
            if (stAb.applyAbility("CantTarget", this, sa)) {
                return false;
            }
        }
    }

    // keywords don't work outside battlefield
    if (!isInZone(ZoneType.Battlefield)) {
        return true;
    }

    if (hasProtectionFrom(sa.getHostCard())) {
        return false;
    }

    if (isPhasedOut()) {
        return false;
    }

    final Card source = sa.getHostCard();
    final MutableBoolean result = new MutableBoolean(true);
    visitKeywords(currentState, new Visitor<String>() {
        @Override
        public void visit(String kw) {
            if (result.isFalse()) {
                return;
            }
            switch (kw) {
            case "Shroud":
                StringBuilder sb = new StringBuilder();
                sb.append("Can target CardUID_").append(String.valueOf(getId()));
                sb.append(" with spells and abilities as though it didn't have shroud.");
                if (!sa.getActivatingPlayer().hasKeyword(sb.toString())) {
                    result.setFalse();
                }
                break;
            case "Hexproof":
                if (sa.getActivatingPlayer().getOpponents().contains(getController())) {
                    if (!sa.getActivatingPlayer()
                            .hasKeyword("Spells and abilities you control can target hexproof creatures")) {
                        result.setFalse();
                    }
                }
                break;
            case "CARDNAME can't be the target of Aura spells.":
                if (source.isAura() && sa.isSpell()) {
                    result.setFalse();
                }
                break;
            case "CARDNAME can't be enchanted.":
                if (source.isAura()) {
                    result.setFalse();
                }
                break;
            case "CARDNAME can't be equipped.":
                if (source.isEquipment()) {
                    result.setFalse();
                }
                break;
            case "CARDNAME can't be the target of red spells or abilities from red sources.":
                if (source.isRed()) {
                    result.setFalse();
                }
                break;
            case "CARDNAME can't be the target of black spells.":
                if (source.isBlack() && sa.isSpell()) {
                    result.setFalse();
                }
                break;
            case "CARDNAME can't be the target of blue spells.":
                if (source.isBlue() && sa.isSpell()) {
                    result.setFalse();
                }
                break;
            case "CARDNAME can't be the target of spells.":
                if (sa.isSpell()) {
                    result.setFalse();
                }
                break;
            }
        }
    });
    if (result.isFalse()) {
        return false;
    }
    if (sa.isSpell() && source.hasStartOfKeyword("SpellCantTarget")) {
        final int keywordPosition = source.getKeywordPosition("SpellCantTarget");
        final String parse = source.getKeywords().get(keywordPosition);
        final String[] k = parse.split(":");
        final String[] restrictions = k[1].split(",");
        if (isValid(restrictions, source.getController(), source)) {
            return false;
        }
    }
    return true;
}

From source file:org.onosproject.store.ecmap.MapDbPersistentStore.java

private void putInternal(K key, V value, Timestamp timestamp) {
    byte[] keyBytes = serializer.encode(key);
    byte[] removedBytes = tombstones.get(keyBytes);

    Timestamp removed = removedBytes == null ? null : serializer.decode(removedBytes);
    if (removed != null && removed.isNewerThan(timestamp)) {
        return;/*from ww w  .  j a  v  a 2  s .c  o  m*/
    }

    final MutableBoolean updated = new MutableBoolean(false);

    items.compute(keyBytes, (k, existingBytes) -> {
        Timestamped<V> existing = existingBytes == null ? null : serializer.decode(existingBytes);
        if (existing != null && existing.isNewerThan(timestamp)) {
            updated.setFalse();
            return existingBytes;
        } else {
            updated.setTrue();
            return serializer.encode(new Timestamped<>(value, timestamp));
        }
    });

    boolean success = updated.booleanValue();

    if (success && removed != null) {
        tombstones.remove(keyBytes, removedBytes);
    }

    database.commit();
}

From source file:org.onosproject.store.ecmap.MapDbPersistentStore.java

private void removeInternal(K key, Timestamp timestamp) {
    byte[] keyBytes = serializer.encode(key);

    final MutableBoolean updated = new MutableBoolean(false);

    items.compute(keyBytes, (k, existingBytes) -> {
        Timestamp existing = existingBytes == null ? null : serializer.decode(existingBytes);
        if (existing != null && existing.isNewerThan(timestamp)) {
            updated.setFalse();
            return existingBytes;
        } else {/*w  w  w  .  ja  v a  2  s  . c  o m*/
            updated.setTrue();
            // remove from items map
            return null;
        }
    });

    if (!updated.booleanValue()) {
        return;
    }

    byte[] timestampBytes = serializer.encode(timestamp);
    byte[] removedBytes = tombstones.get(keyBytes);

    Timestamp removedTimestamp = removedBytes == null ? null : serializer.decode(removedBytes);
    if (removedTimestamp == null) {
        tombstones.putIfAbsent(keyBytes, timestampBytes);
    } else if (timestamp.isNewerThan(removedTimestamp)) {
        tombstones.replace(keyBytes, removedBytes, timestampBytes);
    }

    database.commit();
}