// Path: op1/src/main/java/com/op1/iff/Chunk.java
// public interface Chunk {
// 
//     /**
//      * Returns the ID of this chunk.
//      */
//     ID getChunkID();
// 
//     /**
//      * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the
//      * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes,
//      * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count.
//      */
//     SignedLong getChunkSize();
// 
//     /**
//      * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by
//      * getChunkSize() + 8 [+1 if getChunkSize() is odd].
//      */
//     int getPhysicalSize();
// }
// 
// Path: op1/src/main/java/com/op1/iff/types/ID.java
// public class ID extends DataType {
// 
//     private final String name;
// 
//     public ID(byte[] bytes) {
//         // TODO: ahem, validation?
//         super(bytes, 4);
//         this.name = new String(bytes);
//     }
// 
//     public static ID valueOf(String s) {
//         return new ID(s.getBytes());
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     @Override
//     public String toString() {
//         return getName();
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final ID id = (ID) o;
// 
//         return Arrays.equals(bytes, id.bytes);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return Arrays.hashCode(bytes);
//     }
// }
// 
// Path: op1/src/main/java/com/op1/iff/types/SignedLong.java
// public class SignedLong extends DataType {
// 
// 
//     public SignedLong(byte[] bytes) {
//         super(bytes, 4);
//     }
// 
//     public int toInt() {
//         return ByteBuffer.wrap(bytes).getInt();
//     }
// 
//     public static SignedLong fromInt(int i) {
//         return new SignedLong(ByteBuffer.allocate(4).putInt(i).array());
//     }
// 
//     @Override
//     public String toString() {
//         return String.valueOf(toInt());
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final SignedLong that = (SignedLong) o;
// 
//         return Arrays.equals(bytes, that.bytes);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return Arrays.hashCode(bytes);
//     }
// }


import com.op1.aiff.*;
import com.op1.iff.Chunk;
import com.op1.iff.types.ID;
import com.op1.iff.types.SignedLong;
import java.util.ArrayList;
import java.util.List;
import static com.op1.aiff.ChunkType.APPLICATION;
import static java.lang.String.format;
package com.op1.util;




public class ComplianceCheck {

    private final Aiff aiff;
    private final List<String> problems;

    public ComplianceCheck(Aiff aiff) {
        this.aiff = Check.notNull(aiff, "aiff cannot be null");
        this.problems = new ArrayList<>();
    }

    /**
     * @deprecated please use ComplianceCheck.enforceCompliance(Aiff) instead.
     */
    @Deprecated
    public void enforceCompliance() throws AiffNotCompliantException {

        checkComplianceOfFormChunk();

        if (aiff.getFormType().toString().equals("AIFC")) {
            checkComplianceOfFormatVersionChunk();
        }

        checkComplianceOfCommonChunk();
        checkComplianceOfSoundDataChunk();

        if (aiff.hasChunk(APPLICATION)) {
            checkComplianceOfApplicationChunk();
        }

        if (!problems.isEmpty()) {
            throw new AiffNotCompliantException(problems);
        }
    }

    public static void enforceCompliance(Aiff aiff) throws AiffNotCompliantException {
        new ComplianceCheck(aiff).enforceCompliance();
    }

    private void checkComplianceOfFormChunk() {

        int physicalSizeOfDataPortion = 0;

        physicalSizeOfDataPortion += aiff.getFormType().getSize();

// Path: op1/src/main/java/com/op1/iff/Chunk.java
// public interface Chunk {
// 
//     /**
//      * Returns the ID of this chunk.
//      */
//     ID getChunkID();
// 
//     /**
//      * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the
//      * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes,
//      * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count.
//      */
//     SignedLong getChunkSize();
// 
//     /**
//      * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by
//      * getChunkSize() + 8 [+1 if getChunkSize() is odd].
//      */
//     int getPhysicalSize();
// }
// 
// Path: op1/src/main/java/com/op1/iff/types/ID.java
// public class ID extends DataType {
// 
//     private final String name;
// 
//     public ID(byte[] bytes) {
//         // TODO: ahem, validation?
//         super(bytes, 4);
//         this.name = new String(bytes);
//     }
// 
//     public static ID valueOf(String s) {
//         return new ID(s.getBytes());
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     @Override
//     public String toString() {
//         return getName();
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final ID id = (ID) o;
// 
//         return Arrays.equals(bytes, id.bytes);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return Arrays.hashCode(bytes);
//     }
// }
// 
// Path: op1/src/main/java/com/op1/iff/types/SignedLong.java
// public class SignedLong extends DataType {
// 
// 
//     public SignedLong(byte[] bytes) {
//         super(bytes, 4);
//     }
// 
//     public int toInt() {
//         return ByteBuffer.wrap(bytes).getInt();
//     }
// 
//     public static SignedLong fromInt(int i) {
//         return new SignedLong(ByteBuffer.allocate(4).putInt(i).array());
//     }
// 
//     @Override
//     public String toString() {
//         return String.valueOf(toInt());
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final SignedLong that = (SignedLong) o;
// 
//         return Arrays.equals(bytes, that.bytes);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return Arrays.hashCode(bytes);
//     }
// }


// Path: op1/src/main/java/com/op1/util/ComplianceCheck.java
import com.op1.aiff.*;
import com.op1.iff.Chunk;
import com.op1.iff.types.ID;
import com.op1.iff.types.SignedLong;
import java.util.ArrayList;
import java.util.List;
import static com.op1.aiff.ChunkType.APPLICATION;
import static java.lang.String.format;

package com.op1.util;




public class ComplianceCheck {

    private final Aiff aiff;
    private final List<String> problems;

    public ComplianceCheck(Aiff aiff) {
        this.aiff = Check.notNull(aiff, "aiff cannot be null");
        this.problems = new ArrayList<>();
    }

    /**
     * @deprecated please use ComplianceCheck.enforceCompliance(Aiff) instead.
     */
    @Deprecated
    public void enforceCompliance() throws AiffNotCompliantException {

        checkComplianceOfFormChunk();

        if (aiff.getFormType().toString().equals("AIFC")) {
            checkComplianceOfFormatVersionChunk();
        }

        checkComplianceOfCommonChunk();
        checkComplianceOfSoundDataChunk();

        if (aiff.hasChunk(APPLICATION)) {
            checkComplianceOfApplicationChunk();
        }

        if (!problems.isEmpty()) {
            throw new AiffNotCompliantException(problems);
        }
    }

    public static void enforceCompliance(Aiff aiff) throws AiffNotCompliantException {
        new ComplianceCheck(aiff).enforceCompliance();
    }

    private void checkComplianceOfFormChunk() {

        int physicalSizeOfDataPortion = 0;

        physicalSizeOfDataPortion += aiff.getFormType().getSize();

        for (List<Chunk> chunksById : aiff.getChunksMap().values()) {