net.sf.eBus.messages.EArrayInfo Maven / Gradle / Ivy
The newest version!
//
// Copyright 2023 Charles W. Rapp
//
// 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 net.sf.eBus.messages;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This field-level, run-time annotation is used to define two
* attributes for variable-sized field:
*
* {@code maximumAllowedSize}: defines a variable-sized field's
* maximum allowed size. This attribute is used when serializing
* such fields to determine if there is a buffer overflow.
*
*
*
* Supported Field Types and Default Settings
*
*
* Field Type
* Default Value
*
*
*
*
* {@link java.math.BigInteger BigInteger}
* {@link net.sf.eBus.messages.type.DataType#MAX_BIG_INTEGER_SIZE MAX_BIG_INTEGER_SIZE}
*
*
* {@link net.sf.eBus.messages.EFieldList EFieldList}
* {@link net.sf.eBus.messages.type.DataType#MAX_ARRAY_SIZE MAX_ARRAY_SIZE}
*
*
* {@link net.sf.eBus.messages.EMessageList EMessageList}
* {@link net.sf.eBus.messages.type.DataType#MAX_ARRAY_SIZE MAX_ARRAY_SIZE}
*
*
* eBus message field array
* {@link net.sf.eBus.messages.type.DataType#MAX_ARRAY_SIZE MAX_ARRAY_SIZE}
*
*
*
*
* This annotation is ignored if applied to all other data types.
*
*
* @author Charles W. Rapp
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
public @interface EArrayInfo
{
/**
* Returns field's maximum allowed size in bytes. If
* encoded field exceeds this size, then serialization
* results in a {@code BufferOverflowException}.
*
* This attribute is ignored for all other field types.
* Defaults to value < zero which means that default field
* size (as defined in above table) is used.
*
* @return maximum allowed field size.
*/
int maximumAllowedSize() default -1;
} // end of annotation EArrayInfo