當前位置: 首頁>>代碼示例>>Java>>正文


Java BooleanNode類代碼示例

本文整理匯總了Java中org.cubeengine.converter.node.BooleanNode的典型用法代碼示例。如果您正苦於以下問題:Java BooleanNode類的具體用法?Java BooleanNode怎麽用?Java BooleanNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BooleanNode類屬於org.cubeengine.converter.node包,在下文中一共展示了BooleanNode類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fromNode

import org.cubeengine.converter.node.BooleanNode; //導入依賴的package包/類
@Override
public Boolean fromNode(Node node) throws ConversionException
{
    if (node instanceof BooleanNode)
    {
        return ((BooleanNode)node).getValue();
    }
    String s = node.asText();
    if (s == null)
    {
        return null;
    }
    if ("true".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s)
        || "yes".equalsIgnoreCase(s) || "1".equalsIgnoreCase(s))
    {
        return true;
    }
    if ("false".equalsIgnoreCase(s) || "off".equalsIgnoreCase(s)
        || "no".equalsIgnoreCase(s) || "0".equalsIgnoreCase(s))
    {
        return false;
    }
    throw ConversionException.of(this, node, "Node incompatible with Boolean!");
}
 
開發者ID:CubeEngine,項目名稱:ReflecT,代碼行數:25,代碼來源:BooleanConverter.java

示例2: toNode

import org.cubeengine.converter.node.BooleanNode; //導入依賴的package包/類
@Override
public Node toNode(C object) throws ConversionException
{
    MapNode root = MapNode.emptyMap();
    MapNode config = MapNode.emptyMap();
    if (!object.enable)
    {
        config.set("enable", BooleanNode.falseNode());
    }
    if (object.autoProtect)
    {
        config.set("auto-protect", StringNode.of(object.autoProtectType.name()));
    }
    if (object.defaultFlags != null && !object.defaultFlags.isEmpty())
    {
        ListNode flags = ListNode.emptyList();
        for (ProtectionFlag defaultFlag : object.defaultFlags)
        {
            flags.addNode(StringNode.of(defaultFlag.name()));
        }
        config.set("default-flags", flags);
    }
    if (config.isEmpty())
    {
        return StringNode.of(object.getTitle());
    }
    root.set(object.getTitle(), config);
    return root;
}
 
開發者ID:CubeEngine,項目名稱:modules-main,代碼行數:30,代碼來源:LockConfigConverter.java

示例3: fromNode

import org.cubeengine.converter.node.BooleanNode; //導入依賴的package包/類
@Override
public Level fromNode(Node node) throws ConversionException
{
    if (node instanceof StringNode)
    {
        try
        {
            return Level.parse(((StringNode)node).getValue());
        }
        catch (IllegalArgumentException e)
        {
            throw ConversionException.of(this, node, "Unknown Level: " + ((StringNode)node).getValue(), e);
        }
    }
    else if (node instanceof BooleanNode && !((BooleanNode)node).getValue())
    {
        // OFF is interpreted as a boolean false, ALL as a boolean true
        if ((Boolean)node.getValue())
        {
            return Level.ALL;
        }
        else
        {
            return Level.OFF;
        }
    }
    throw ConversionException.of(this, node, "Node is not a StringNode OR BooleanNode!");
}
 
開發者ID:CubeEngine,項目名稱:ReflecT,代碼行數:29,代碼來源:LevelConverter.java

示例4: fromNode

import org.cubeengine.converter.node.BooleanNode; //導入依賴的package包/類
@Override
public C fromNode(Node node) throws ConversionException
{
    if (node instanceof NullNode) return null;
    C configuration;
    if (node instanceof StringNode)
    {
        configuration = fromString(node.asText());
    }
    else
    {
        MapNode root = (MapNode)node;
        if (root.isEmpty()) return null;
        String next = root.getOriginalKey(root.getValue().keySet().iterator().next());
        MapNode config = (MapNode)root.get(next);
        configuration = fromString(next);
        for (Entry<String, Node> entry : config.getValue().entrySet())
        {
            if (entry.getKey().equals("enable"))
            {
                configuration.enable = ((BooleanNode)entry.getValue()).getValue();
            }
            if (entry.getKey().equals("auto-protect"))
            {
                configuration.autoProtect = true;
                configuration.autoProtectType = LockType.valueOf(entry.getValue().asText());
            }
            if (entry.getKey().equals("default-flags"))
            {
                ListNode list = (ListNode)entry.getValue();
                configuration.defaultFlags = new ArrayList<>();
                for (Node listedNode : list.getValue())
                {
                    ProtectionFlag flag = ProtectionFlag.valueOf(listedNode.asText());
                    configuration.defaultFlags.add(flag);
                    if (configuration.protectedType.supportedFlags.contains(flag))
                    {
                    }
                    else
                    {
                        // TODO containers that can be redstoneactivated
                        logger.warn("[Locker] Unsupported flag for protectedType! {}: {}", configuration.protectedType.name(), flag.name());
                    }
                }
            }
        }
    }
    return configuration;
}
 
開發者ID:CubeEngine,項目名稱:modules-main,代碼行數:50,代碼來源:LockConfigConverter.java

示例5: toNode

import org.cubeengine.converter.node.BooleanNode; //導入依賴的package包/類
@Override
public Node toNode(Boolean object) throws ConversionException
{
    return BooleanNode.of(object);
}
 
開發者ID:CubeEngine,項目名稱:ReflecT,代碼行數:6,代碼來源:BooleanConverter.java

示例6: convertValue

import org.cubeengine.converter.node.BooleanNode; //導入依賴的package包/類
private Tag<?> convertValue(String name, Node value)
{
    if (value instanceof MapNode)
    {
        CompoundMap map = new CompoundMap();
        this.convertMap(map, ((MapNode)value).getValue(), (MapNode)value);
        return new CompoundTag(name, map);
    }
    else if (value instanceof ListNode)
    {
        List<Tag> tagList = new ArrayList<Tag>();
        java.lang.Integer i = 0;
        for (Node node : ((ListNode)value).getValue())
        {
            i++;
            tagList.add(this.convertValue(i.toString(), node));
        }
        if (tagList.size() == 0)
        {
            return new ListTag(name, CompoundTag.class, tagList);
        }
        return new ListTag(name, tagList.get(0).getClass(), tagList);
    }
    else if (value instanceof BooleanNode)
    {
        return new ByteTag(name, (Boolean)value.getValue());
    }
    else if (value instanceof ByteNode)
    {
        return new ByteTag(name, (Byte)value.getValue());
    }
    else if (value instanceof CharNode)
    {
        return new StringTag(name, value.getValue().toString());
    }
    else if (value instanceof DoubleNode)
    {
        return new DoubleTag(name, (Double)value.getValue());
    }
    else if (value instanceof FloatNode)
    {
        return new FloatTag(name, (Float)value.getValue());
    }
    else if (value instanceof IntNode)
    {
        return new IntTag(name, (Integer)value.getValue());
    }
    else if (value instanceof LongNode)
    {
        return new LongTag(name, (Long)value.getValue());
    }
    else if (value instanceof ShortNode)
    {
        return new ShortTag(name, (Short)value.getValue());
    }
    else if (value instanceof StringNode)
    {
        return new StringTag(name, (String)value.getValue());
    }
    else if (value instanceof NullNode)
    {
        return new EndTag();
    }
    throw new IllegalStateException("Unknown Node! " + value.getClass().getName());
}
 
開發者ID:CubeEngine,項目名稱:ReflecT,代碼行數:66,代碼來源:NBTCodec.java


注:本文中的org.cubeengine.converter.node.BooleanNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。