Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later
// version.
//
// This library is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General
// Public License along with this library; if not, write to the
//
// Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330,
// Boston, MA
// 02111-1307 USA
//
// The Initial Developer of the Original Code is Charles W. Rapp.
// Portions created by Charles W. Rapp are
// Copyright 2012, 2013, 2016, 2019, 2020. Charles W. Rapp
// All Rights Reserved.
//
package net.sf.eBusx.monitor;
import java.io.Serializable;
import java.util.Arrays;
import net.sf.eBus.messages.EReplyMessage;
import net.sf.eBus.messages.EReplyMessage.ReplyStatus;
/**
* Returns the currently registered monitored objects within the
* eBus virtual machine, specified as an array of
* {@link MonitorId}s. This message is sent in reply to a
* {@link MonitoredObjectRequest} with the subject
* {@link Monitor#MONITOR_REQUEST}.
*
* @see MonitoredObjectRequest
*
* @author Charles Rapp
*/
public final class MonitoredObjectReply
extends EReplyMessage
implements Serializable
{
//---------------------------------------------------------------
// Member data.
//
//-----------------------------------------------------------
// Constants.
//
/**
* Serialization version identifier.
*/
private static final long serialVersionUID = 0x050200L;
//-----------------------------------------------------------
// Locals.
//
/**
* The currently registered monitor objects.
*/
public final MonitorId[] instances;
//---------------------------------------------------------------
// Member methods.
//
//-----------------------------------------------------------
// Constructors.
//
/**
* Creates a new MonitoredObjectReply instance for the
* given monitored objects.
* @param subject the request subject.
* @param ids monitored object identifiers.
*/
@Deprecated
public MonitoredObjectReply(final String subject,
final MonitorId[] ids)
{
this (subject,
System.currentTimeMillis(),
ReplyStatus.OK_FINAL,
null,
ids);
} // end of MonitoredObjectReply(MonitorId[])
/**
* Creates a monitored object reply from the deserialized
* header and monitor identifiers.
* @param subject the request subject.
* @param timestamp the message timestamp.
* @param status the reply status.
* @param reason the reply reason.
* @param ids the currently registered monitor identifiers.
*/
@Deprecated
public MonitoredObjectReply(final String subject,
final long timestamp,
final ReplyStatus status,
final String reason,
final MonitorId[] ids)
{
super (subject, timestamp, status, reason);
instances = Arrays.copyOf(ids, ids.length);
} // end of MonitoredObjectReply(...)
private MonitoredObjectReply(final Builder builder)
{
super (builder);
this.instances = builder.mInstances;
} // end of MonitoredObjectReply(Builder)
//
// end of Constructors.
//-----------------------------------------------------------
//-----------------------------------------------------------
// Object Method Overrides.
//
@Override
public boolean equals(final Object o)
{
return (super.equals(o));
} // end of equals(Object)
@Override
public int hashCode()
{
return (super.hashCode());
} // end of hashCode()
//
// end of Object Method Overrides.
//-----------------------------------------------------------
/**
* Returns a new instance of a {@code MonitoredObjectReply}
* message builder.
* @return new message builder instance.
*/
public static Builder builder()
{
return (new Builder());
} // end of builder()
//---------------------------------------------------------------
// Inner classes.
//
public static final class Builder
extends EReplyMessage.Builder
{
//-----------------------------------------------------------
// Member data.
//
//-------------------------------------------------------
// Locals.
//
private MonitorId[] mInstances;
//-----------------------------------------------------------
// Member methods.
//
//-------------------------------------------------------
// Constructors.
//
private Builder()
{
super (MonitoredObjectReply.class);
} // end of Builder()
//
// end of Constructors.
//-------------------------------------------------------
//-------------------------------------------------------
// Builder Method Overrides.
//
@Override
protected MonitoredObjectReply buildImpl()
{
return (new MonitoredObjectReply(this));
} // end of buildImpl()
@Override
protected Validator validate(final Validator problems)
{
return (super.validate(problems)
.requireNotNull(mInstances, "instance"));
} // end of validate(Validator)
//
// end of Builder Method Overrides.
//-------------------------------------------------------
//-------------------------------------------------------
// Set Methods.
//
public Builder instances(final MonitorId[] ids)
{
if (ids == null)
{
throw (new NullPointerException("ids is null"));
}
final int numIds = ids.length;
mInstances = new MonitorId[numIds];
System.arraycopy(ids, 0, mInstances, 0, numIds);
return (this);
} // end of instances(MonitorId[])
//
// end of Set Methods.
//-------------------------------------------------------
} // end of class Builder
} // end of class MonitoredObjectReply