Top Description Inners Fields Constructors Methods
org.wildfly.common.net

public final Class CidrAddressTable<T>

extends Object
implements Iterable<CidrAddressTable.Mapping<T>>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Imports
java.net.Inet4Address, .InetAddress, java.util.Arrays, .Iterator, .NoSuchElementException, .Objects, .Spliterator, .Spliterators, java.util.concurrent.atomic.AtomicReference, org.wildfly.common.Assert

A table for mapping IP addresses to objects using CidrAddress instances for matching.
Author
David M. Lloyd

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CidrAddressTable.Mapping<
the value type
T
>

A single mapping in the table.

Field Summary

Modifier and TypeField and Description
private final AtomicReference<CidrAddressTable.Mapping<T>[]>
private static final CidrAddressTable.Mapping<T>[]

Constructor Summary

AccessConstructor and Description
public
private

Method Summary

Modifier and TypeMethod and Description
public void
public CidrAddressTable<T>
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
private int
doFind(CidrAddressTable.Mapping<T>[] table, byte[] bytes, int maskBits, final int scopeId)

private CidrAddressTable.Mapping<T>
doGet(CidrAddressTable.Mapping<T>[] table, byte[] bytes, final int netmaskBits, final int scopeId)

private T
doPut(final CidrAddress block, final T expect, final T update, final boolean putIfAbsent, final boolean putIfPresent)

private static <T> CidrAddressTable.Mapping<T>[]
public T
get(InetAddress address)

public T
getOrDefault(InetAddress address, T defVal)

public boolean
public Iterator<CidrAddressTable.Mapping<T>>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
public T
put(CidrAddress block, T value)

public T
putIfAbsent(CidrAddress block, T value)

public T
public boolean
removeExact(CidrAddress block, T expect)

public T
replaceExact(CidrAddress block, T value)

public boolean
replaceExact(CidrAddress block, T expect, T update)

public int
size()

public Spliterator<CidrAddressTable.Mapping<T>>
spliterator()

Overrides default java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

mappingsRefback to summary
private final AtomicReference<CidrAddressTable.Mapping<T>[]> mappingsRef
NO_MAPPINGSback to summary
private static final CidrAddressTable.Mapping<T>[] NO_MAPPINGS
Annotations
@SuppressWarnings:rawtypes

Constructor Detail

CidrAddressTableback to summary
public CidrAddressTable()
CidrAddressTableback to summary
private CidrAddressTable(CidrAddressTable.Mapping<T>[] mappings)

Method Detail

clearback to summary
public void clear()
cloneback to summary
public CidrAddressTable<T> clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:CidrAddressTable<T>

a clone of this instance.

doFindback to summary
private int doFind(CidrAddressTable.Mapping<T>[] table, byte[] bytes, int maskBits, final int scopeId)
doGetback to summary
private CidrAddressTable.Mapping<T> doGet(CidrAddressTable.Mapping<T>[] table, byte[] bytes, final int netmaskBits, final int scopeId)
doPutback to summary
private T doPut(final CidrAddress block, final T expect, final T update, final boolean putIfAbsent, final boolean putIfPresent)
emptyback to summary
private static <T> CidrAddressTable.Mapping<T>[] empty()
Annotations
@SuppressWarnings:unchecked
getback to summary
public T get(InetAddress address)
getOrDefaultback to summary
public T getOrDefault(InetAddress address, T defVal)
isEmptyback to summary
public boolean isEmpty()
iteratorback to summary
public Iterator<CidrAddressTable.Mapping<T>> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<CidrAddressTable.Mapping<T>>

an Iterator.

putback to summary
public T put(CidrAddress block, T value)
putIfAbsentback to summary
public T putIfAbsent(CidrAddress block, T value)
removeExactback to summary
public T removeExact(CidrAddress block)
removeExactback to summary
public boolean removeExact(CidrAddress block, T expect)
replaceExactback to summary
public T replaceExact(CidrAddress block, T value)
replaceExactback to summary
public boolean replaceExact(CidrAddress block, T expect, T update)
sizeback to summary
public int size()
spliteratorback to summary
public Spliterator<CidrAddressTable.Mapping<T>> spliterator()

Overrides default java.lang.Iterable.spliterator.

Doc from java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.

Returns:Spliterator<CidrAddressTable.Mapping<T>>

a Spliterator over the elements described by this Iterable.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

org.wildfly.common.net back to summary

public final Class CidrAddressTable.Mapping<T>

extends Object
Class Inheritance
Type Parameters
<T>
the value type

A single mapping in the table.

Field Summary

Modifier and TypeField and Description
pack-priv final CidrAddressTable.Mapping<T>
pack-priv final CidrAddress
pack-priv final T

Constructor Summary

AccessConstructor and Description
pack-priv
Mapping(final CidrAddress range, final T value, final CidrAddressTable.Mapping<T> parent)

Method Summary

Modifier and TypeMethod and Description
public CidrAddressTable.Mapping<T>

Returns:

the parent of this entry, or null if there is no parent
getParent
()

Get the parent of this entry, if any.

public CidrAddress

Returns:

the address range of this entry (not null)
getRange
()

Get the address range of this entry.

public T

Returns:

the stored value of this entry
getValue
()

Get the stored value of this entry.

pack-priv CidrAddressTable.Mapping<T>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

parentback to summary
pack-priv final CidrAddressTable.Mapping<T> parent
rangeback to summary
pack-priv final CidrAddress range
valueback to summary
pack-priv final T value

Constructor Detail

Mappingback to summary
pack-priv Mapping(final CidrAddress range, final T value, final CidrAddressTable.Mapping<T> parent)

Method Detail

getParentback to summary
public CidrAddressTable.Mapping<T> getParent()

Get the parent of this entry, if any.

Returns:CidrAddressTable.Mapping<T>

the parent of this entry, or null if there is no parent

getRangeback to summary
public CidrAddress getRange()

Get the address range of this entry.

Returns:CidrAddress

the address range of this entry (not null)

getValueback to summary
public T getValue()

Get the stored value of this entry.

Returns:T

the stored value of this entry

withNewParentback to summary
pack-priv CidrAddressTable.Mapping<T> withNewParent(CidrAddressTable.Mapping<T> newParent)