001/*
002 * Trident - A Multithreaded Server Alternative
003 * Copyright 2014 The TridentSDK Team
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package net.tridentsdk.meta.nbt;
019
020/**
021 * @author The TridentSDK Team
022 * @since 0.3-alpha-DP
023 */
024public enum TagType {
025    NULL(-1, NullTag.class),
026
027    END(0, null),
028
029    BYTE(1, ByteTag.class),
030
031    SHORT(2, ShortTag.class),
032
033    INT(3, IntTag.class),
034
035    LONG(4, LongTag.class),
036
037    FLOAT(5, FloatTag.class),
038
039    DOUBLE(6, DoubleTag.class),
040
041    BYTE_ARRAY(7, ByteArrayTag.class),
042
043    STRING(8, StringTag.class),
044
045    LIST(9, ListTag.class),
046
047    COMPOUND(10, CompoundTag.class),
048
049    INT_ARRAY(11, IntArrayTag.class);
050
051    final int id;
052    final Class<? extends NBTTag> implClass;
053
054    TagType(int id, Class<? extends NBTTag> implClass) {
055        this.id = id;
056        this.implClass = implClass;
057    }
058
059    public static TagType fromId(byte fromId) {
060        for (TagType type : TagType.values()) {
061            if (type.id == fromId) {
062                return type;
063            }
064        }
065        return NULL;
066    }
067
068    public Class<? extends NBTTag> implementation() {
069        return this.implClass;
070    }
071
072    public int id() {
073        return this.id;
074    }
075}