File indexing completed on 2024-12-15 04:19:54

0001 package mso.generator.utils;
0002 
0003 import java.util.SortedSet;
0004 
0005 import mso.generator.utils.Member.ByteArray;
0006 
0007 public class FixedChoice extends Type {
0008 
0009     private static int getSize(SortedSet<ByteArray> texts) {
0010         if (texts.size() == 0) {
0011             return 0;
0012         }
0013         int size = -2;
0014         for (ByteArray b : texts) {
0015             if (size == -2) {
0016                 size = 8 * b.data.length;
0017             } else if (size != 8 * b.data.length) {
0018                 size = -1;
0019             }
0020         }
0021         return size;
0022     }
0023 
0024     FixedChoice(TypeRegistry registry, String name, SortedSet<ByteArray> texts,
0025             boolean optional) {
0026         super(registry, name, getSize(texts));
0027     }
0028 
0029 }