package edu.brown.cs.systems.tracingplane.atom_layer.impl;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.List;
import edu.brown.cs.systems.tracingplane.atom_layer.AtomLayer;
import edu.brown.cs.systems.tracingplane.transit_layer.Baggage;

/**
 * The simple implementation of the context layer that can be used in lieu of a full baggage layer. Simply merges bags
 * lexicographically, removes duplicates, and supports overflow.
 */
public class RawAtomLayer implements AtomLayer<RawBaggageAtoms> {

    @Override
    public boolean isInstance(Baggage baggage) {
        return baggage == null || baggage instanceof RawBaggageAtoms;
    }

    @Override
    public RawBaggageAtoms newInstance() {
        return null;
    }

    @Override
    public void discard(RawBaggageAtoms baggage) {
        if (baggage != null) {
            baggage.discard();
        }
    }

    @Override
    public RawBaggageAtoms branch(RawBaggageAtoms from) {
        if (from != null) {
            return from.branch();
        } else {
            return null;
        }
    }

    @Override
    public RawBaggageAtoms join(RawBaggageAtoms left, RawBaggageAtoms right) {
        if (left == null) {
            return right;
        } else if (right == null) {
            return left;
        } else {
            return left.mergeWith(right);
        }
    }

    @Override
    public RawBaggageAtoms wrap(List<ByteBuffer> atoms) {
        if (atoms == null || atoms.size() == 0) {
            return null;
        } else {
            return new RawBaggageAtoms(atoms);
        }
    }

    @Override
    public List<ByteBuffer> atoms(RawBaggageAtoms baggage) {
        if (baggage != null && baggage.contents.atoms != null && baggage.contents.atoms.size() > 0) {
            return baggage.contents.atoms;
        } else {
            return null;
        }
    }

    @Override
    public RawBaggageAtoms deserialize(byte[] serialized, int offset, int length) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public RawBaggageAtoms readFrom(InputStream in) throws IOException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public byte[] serialize(RawBaggageAtoms baggage) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void writeTo(OutputStream out, RawBaggageAtoms baggage) throws IOException {
        // TODO Auto-generated method stub
        
    }

}

@@ -57,93 +57,8 @@
 l;%0A%0A
-import java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0A
 impo
@@ -1848,634 +1848,6 @@
  %7D%0A%0A
-    @Override%0A    public RawBaggageAtoms deserialize(byte%5B%5D serialized, int offset, int length) %7B%0A        // TODO Auto-generated method stub%0A        return null;%0A    %7D%0A%0A    @Override%0A    public RawBaggageAtoms readFrom(InputStream in) throws IOException %7B%0A        // TODO Auto-generated method stub%0A        return null;%0A    %7D%0A%0A    @Override%0A    public byte%5B%5D serialize(RawBaggageAtoms baggage) %7B%0A        // TODO Auto-generated method stub%0A        return null;%0A    %7D%0A%0A    @Override%0A    public void writeTo(OutputStream out, RawBaggageAtoms baggage) throws IOException %7B%0A        // TODO Auto-generated method stub%0A        %0A    %7D%0A%0A
 %7D%0A

Remove accidental interface overrides in RawAtomLayer