/**
 * Copyright (C) 2011 Red Hat, Inc. (jdcasey@commonjava.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.commonjava.indy.folo.model;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.HashSet;
import java.util.Set;

public class TrackedContent
        implements Externalizable
{

    private TrackingKey key;

    private Set<TrackedContentEntry> uploads;

    private Set<TrackedContentEntry> downloads;

    public TrackedContent( final TrackingKey key, final Set<TrackedContentEntry> uploads,
                           final Set<TrackedContentEntry> downloads )
    {
        this.key = key;
        this.uploads = uploads;
        this.downloads = downloads;
    }

    public TrackingKey getKey()
    {
        return key;
    }

    public Set<TrackedContentEntry> getUploads()
    {
        return uploads;
    }

    public Set<TrackedContentEntry> getDownloads()
    {
        return downloads;
    }

    @Override
    public boolean equals( Object o )
    {
        if ( this == o )
        {
            return true;
        }
        if ( !( o instanceof TrackedContent ) )
        {
            return false;
        }

        TrackedContent that = (TrackedContent) o;

        return getKey() != null ? getKey().equals( that.getKey() ) : that.getKey() == null;

    }

    @Override
    public int hashCode()
    {
        return getKey() != null ? getKey().hashCode() : 0;
    }

    @Override
    public void writeExternal( ObjectOutput objectOutput )
            throws IOException
    {
        objectOutput.writeObject( key );
        objectOutput.writeObject( uploads );
        objectOutput.writeObject( downloads );
    }

    @Override
    public void readExternal( ObjectInput objectInput )
            throws IOException, ClassNotFoundException
    {
        key = (TrackingKey) objectInput.readObject();
        Set<TrackedContentEntry> ups = (Set<TrackedContentEntry>) objectInput.readObject();
        uploads = ups == null ? new HashSet<>() : new HashSet<>( ups );

        Set<TrackedContentEntry> downs = (Set<TrackedContentEntry>) objectInput.readObject();
        downloads = downs == null ? new HashSet<>() : new HashSet<>( downs );
    }
}

@@ -1017,24 +1017,55 @@
 downloads;%0A%0A
+    public TrackedContent()%7B%7D%0A%0A
     public T

Add public ctor to TrackedContent to fix deserialization