当前位置: 首页>>代码示例>>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;未经允许,请勿转载。