package com.intellectualcrafters.jnbt; import static com.google.common.base.Preconditions.checkNotNull; /** * The {@code TAG_Int_Array} tag. */ public final class IntArrayTag extends Tag { private final int[] value; /** * Creates the tag with an empty name. * * @param value the value of the tag */ public IntArrayTag(int[] value) { checkNotNull(value); this.value = value; } /** * Creates the tag. * * @param name the name of the tag * @param value the value of the tag */ public IntArrayTag(String name, int[] value) { super(name); checkNotNull(value); this.value = value; } @Override public int[] getValue() { return this.value; } @Override public String toString() { StringBuilder hex = new StringBuilder(); for (int b : this.value) { String hexDigits = Integer.toHexString(b).toUpperCase(); if (hexDigits.length() == 1) { hex.append("0"); } hex.append(hexDigits).append(" "); } String name = getName(); String append = ""; if (name != null && !name.isEmpty()) { append = "(\"" + getName() + "\")"; } return "TAG_Int_Array" + append + ": " + hex; } }