All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.controller.cluster.messaging.AbortSlicing Maven / Gradle / Ivy

There is a newer version: 10.0.4
Show newest version
/*
 * Copyright (c) 2017 Inocybe Technologies and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.controller.cluster.messaging;

import static java.util.Objects.requireNonNull;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
import org.opendaylight.yangtools.concepts.Identifier;

/**
 * Message sent to abort slicing.
 *
 * @author Thomas Pantelis
 */
class AbortSlicing implements Serializable {
    private static final long serialVersionUID = 1L;

    private final Identifier identifier;

    AbortSlicing(final Identifier identifier) {
        this.identifier = requireNonNull(identifier);
    }

    Identifier getIdentifier() {
        return identifier;
    }

    @Override
    public String toString() {
        return "AbortSlicing [identifier=" + identifier + "]";
    }

    private Object writeReplace() {
        return new Proxy(this);
    }

    private static class Proxy implements Externalizable {
        private static final long serialVersionUID = 1L;

        private AbortSlicing abortSlicing;

        // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
        // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
        @SuppressWarnings("checkstyle:RedundantModifier")
        public Proxy() {
        }

        Proxy(final AbortSlicing abortSlicing) {
            this.abortSlicing = abortSlicing;
        }

        @Override
        public void writeExternal(final ObjectOutput out) throws IOException {
            out.writeObject(abortSlicing.identifier);
        }

        @Override
        public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
            abortSlicing = new AbortSlicing((Identifier) in.readObject());
        }

        private Object readResolve() {
            return abortSlicing;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy