001package net.tnemc.item.persistent.impl; 002/* 003 * The New Item Library 004 * Copyright (C) 2022 - 2025 Daniel "creatorfromhell" Vidmar 005 * 006 * This program is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public License 017 * along with this program; if not, write to the Free Software Foundation, 018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 */ 020 021import net.tnemc.item.persistent.PersistentDataType; 022 023/** 024 * PersistentByte 025 * 026 * @author creatorfromhell 027 * @since 0.2.0.0 028 */ 029public class PersistentByte extends PersistentDataType<Byte> { 030 031 public PersistentByte(final String namespace, final String key) { 032 033 super(namespace, key); 034 } 035 036 /** 037 * Returns the type of the PersistentDataType. 038 * 039 * @return The type of the PersistentDataType as a String. 040 * @since 0.2.0.0 041 */ 042 @Override 043 public String type() { 044 045 return "byte"; 046 } 047 048 /** 049 * Encodes the value of the PersistentDataType into a string representation. 050 * 051 * @return The encoded string representation of the value 052 * @since 0.2.0.0 053 */ 054 @Override 055 public String encode() { 056 057 return value.toString(); 058 } 059 060 /** 061 * Decodes the given encoded string and sets the decoded value. 062 * 063 * @param encoded The string to be decoded 064 * @since 0.2.0.0 065 */ 066 @Override 067 public Byte decode(final String encoded) throws IllegalArgumentException { 068 069 return Byte.parseByte(encoded); 070 } 071}