本文整理汇总了Java中org.wildfly.common.Assert类的典型用法代码示例。如果您正苦于以下问题:Java Assert类的具体用法?Java Assert怎么用?Java Assert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Assert类属于org.wildfly.common包,在下文中一共展示了Assert类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: OutboundSocketBinding
import org.wildfly.common.Assert; //导入依赖的package包/类
/**
* Creates an outbound socket binding
*
* @param name Name of the outbound socket binding
* @param socketBindingManager The socket binding manager
* @param destinationAddress The destination address to which this socket will be "connected". Cannot be null or empty string.
* @param destinationPort The destination port. Cannot be < 0.
* @param sourceNetworkInterface (Optional) source network interface which will be used as the "source" of the socket binding
* @param sourcePort (Optional) source port. Cannot be null or < 0
* @param fixedSourcePort True if the <code>sourcePort</code> has to be used as a fixed port number. False if the <code>sourcePort</code>
* will be added to the port offset while determining the absolute source port.
*/
public OutboundSocketBinding(final String name, final SocketBindingManager socketBindingManager,
final String destinationAddress, final int destinationPort,
final NetworkInterfaceBinding sourceNetworkInterface, final Integer sourcePort,
final boolean fixedSourcePort) {
Assert.checkNotNullParam("name", name);
Assert.checkNotEmptyParam("name", name);
Assert.checkNotNullParam("socketBindingManager", socketBindingManager);
Assert.checkNotNullParam("destinationAddress", destinationAddress);
Assert.checkMinimumParameter("destinationPort", 0, destinationPort);
this.name = name;
this.socketBindingManager = socketBindingManager;
this.unresolvedDestinationAddress = destinationAddress;
this.destinationPort = destinationPort;
this.sourceNetworkInterface = sourceNetworkInterface;
this.sourcePort = sourcePort;
this.fixedSourcePort = fixedSourcePort;
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:30,代码来源:OutboundSocketBinding.java
示例2: create
import org.wildfly.common.Assert; //导入依赖的package包/类
/**
* Create a reference of a given type with the provided value and attachment. If the reference type is
* {@link Reference.Type#STRONG} or {@link Reference.Type#NULL} then the reference queue argument is ignored. If
* the reference type is {@link Reference.Type#NULL} then the value and attachment arguments are ignored.
*
* @param type the reference type
* @param value the reference value
* @param attachment the attachment value
* @param referenceQueue the reference queue to use, if any
* @param <T> the reference value type
* @param <A> the reference attachment type
* @return the reference
*/
public static <T, A> Reference<T, A> create(Reference.Type type, T value, A attachment, ReferenceQueue<? super T> referenceQueue) {
Assert.checkNotNullParam("type", type);
if (referenceQueue == null) return create(type, value, attachment);
if (value == null) return getNullReference();
switch (type) {
case STRONG:
return new StrongReference<T, A>(value, attachment);
case WEAK:
return new WeakReference<T, A>(value, attachment, referenceQueue);
case PHANTOM:
return new PhantomReference<T, A>(value, attachment, referenceQueue);
case SOFT:
return new SoftReference<T, A>(value, attachment, referenceQueue);
case NULL:
return getNullReference();
default:
throw Assert.impossibleSwitchCase(type);
}
}
开发者ID:wildfly,项目名称:wildfly-common,代码行数:33,代码来源:References.java
示例3: getConnectionAddOperation
import org.wildfly.common.Assert; //导入依赖的package包/类
static ModelNode getConnectionAddOperation(final String connectionName, final String outboundSocketBindingRef, final ModelNode userName, final String securityRealm, PathAddress address) {
Assert.checkNotNullParam("connectionName", connectionName);
Assert.checkNotEmptyParam("connectionName", connectionName);
Assert.checkNotNullParam("outboundSocketBindingRef", outboundSocketBindingRef);
Assert.checkNotEmptyParam("outboundSocketBindingRef", outboundSocketBindingRef);
final ModelNode addOperation = new ModelNode();
addOperation.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
// /subsystem=remoting/local-outbound-connection=<connection-name>
addOperation.get(ModelDescriptionConstants.OP_ADDR).set(address.toModelNode());
// set the other params
addOperation.get(CommonAttributes.OUTBOUND_SOCKET_BINDING_REF).set(outboundSocketBindingRef);
// optional connection creation options
if (userName != null) {
addOperation.get(CommonAttributes.USERNAME).set(userName);
}
if (securityRealm != null) {
addOperation.get(CommonAttributes.SECURITY_REALM).set(securityRealm);
}
return addOperation;
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:24,代码来源:RemotingSubsystem11Parser.java
示例4: create
import org.wildfly.common.Assert; //导入依赖的package包/类
static CidrAddress create(byte[] addressBytes, int netmaskBits, boolean clone) {
Assert.checkNotNullParam("networkAddress", addressBytes);
Assert.checkMinimumParameter("netmaskBits", 0, netmaskBits);
final int length = addressBytes.length;
if (length == 4) {
Assert.checkMaximumParameter("netmaskBits", 32, netmaskBits);
if (netmaskBits == 0) {
return INET4_ANY_CIDR;
}
} else if (length == 16) {
Assert.checkMaximumParameter("netmaskBits", 128, netmaskBits);
if (netmaskBits == 0) {
return INET6_ANY_CIDR;
}
} else {
throw CommonMessages.msg.invalidAddressBytes(length);
}
final byte[] bytes = clone ? addressBytes.clone() : addressBytes;
maskBits0(bytes, netmaskBits);
String name = Inet.toOptimalString(bytes);
try {
return new CidrAddress(InetAddress.getByAddress(name, bytes), netmaskBits);
} catch (UnknownHostException e) {
throw Assert.unreachableCode();
}
}
开发者ID:wildfly,项目名称:wildfly-common,代码行数:27,代码来源:CidrAddress.java
示例5: convertPath
import org.wildfly.common.Assert; //导入依赖的package包/类
static String convertPath(String relativePath) {
Assert.checkNotNullParam("relativePath", relativePath);
Assert.checkNotEmptyParam("relativePath", relativePath);
if (relativePath.charAt(0) == '/') {
if (relativePath.length() == 1) {
throw ControllerLogger.ROOT_LOGGER.invalidRelativePathValue(relativePath);
}
return relativePath.substring(1);
}
else if (relativePath.indexOf(":\\") == 1) {
throw ControllerLogger.ROOT_LOGGER.pathIsAWindowsAbsolutePath(relativePath);
}
else {
if(isWindows()) {
return relativePath.replace("/", File.separator);
} else {
return relativePath.replace("\\", File.separator);
}
}
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:RelativePathService.java
示例6: SimpleResourceDefinition
import org.wildfly.common.Assert; //导入依赖的package包/类
/**
* {@link ResourceDefinition} that uses the given {code descriptionProvider} to describe the resource.
*
* @param pathElement the path. Can be {@code null}.
* @param descriptionProvider the description provider. Cannot be {@code null}
* @throws IllegalArgumentException if {@code descriptionProvider} is {@code null}.
* @deprecated Use {@link #SimpleResourceDefinition(Parameters)}
*/
@Deprecated
public SimpleResourceDefinition(final PathElement pathElement, final DescriptionProvider descriptionProvider) {
//Can be removed when we get to 3.0.0
Assert.checkNotNullParam("descriptionProvider", descriptionProvider);
this.pathElement = pathElement;
this.descriptionResolver = null;
this.descriptionProvider = descriptionProvider;
this.addHandler = null;
this.removeHandler = null;
this.addRestartLevel = null;
this.removeRestartLevel = null;
this.deprecationData = null;
this.runtime = false;
this.orderedChild = false;
this.capabilities = NO_CAPABILITIES;
this.incorporatingCapabilities = null;
this.accessConstraints = Collections.emptyList();
this.minOccurs = 0;
this.maxOccurs = Integer.MAX_VALUE;
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:29,代码来源:SimpleResourceDefinition.java
示例7: SelectorPermission
import org.wildfly.common.Assert; //导入依赖的package包/类
public SelectorPermission(final String name, final String actions) {
super(name);
Assert.checkNotNullParam("name", name);
Assert.checkNotNullParam("actions", actions);
final String[] actionArray = actions.split("\\s*,\\s*");
int q = 0;
for (String action : actionArray) {
if (action.equalsIgnoreCase("get")) {
q |= ACTION_GET;
} else if (action.equalsIgnoreCase("set")) {
q |= ACTION_SET;
} else if (action.equalsIgnoreCase("change")) {
q |= ACTION_CHANGE;
} else if (action.equals("*")) {
q |= ACTION_GET | ACTION_SET | ACTION_CHANGE;
break;
}
}
this.actions = q;
}
开发者ID:wildfly,项目名称:wildfly-common,代码行数:21,代码来源:SelectorPermission.java
示例8: registerOverrideModel
import org.wildfly.common.Assert; //导入依赖的package包/类
@Override
public ManagementResourceRegistration registerOverrideModel(String name, OverrideDescriptionProvider descriptionProvider) {
Assert.checkNotNullParam("name", name);
Assert.checkNotNullParam("descriptionProvider", descriptionProvider);
if (parent == null) {
throw ControllerLogger.ROOT_LOGGER.cannotOverrideRootRegistration();
}
if (!PathElement.WILDCARD_VALUE.equals(valueString)) {
throw ControllerLogger.ROOT_LOGGER.cannotOverrideNonWildCardRegistration(valueString);
}
PathElement pe = PathElement.pathElement(parent.getKeyName(), name);
final SimpleResourceDefinition rd = new SimpleResourceDefinition(pe, new OverrideDescriptionCombiner(getModelDescription(PathAddress.EMPTY_ADDRESS), descriptionProvider)) {
@Override
public List<AccessConstraintDefinition> getAccessConstraints() {
return AbstractResourceRegistration.this.getAccessConstraints();
}
};
return parent.getParent().registerSubModel(rd);
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:24,代码来源:AbstractResourceRegistration.java
示例9: contentEquals
import org.wildfly.common.Assert; //导入依赖的package包/类
/**
* Determine if the remaining contents of this iterator are identical to the remaining contents of the other iterator. If the
* contents are not equal, the iterators will be positioned at the location of the first difference. If the contents
* are equal, the iterators will both be positioned at the end of their contents.
*
* @param other the other byte iterator
* @return {@code true} if the contents are equal, {@code false} otherwise
*/
public final boolean contentEquals(ByteIterator other) {
Assert.checkNotNullParam("other", other);
for (;;) {
if (hasNext()) {
if (! other.hasNext()) {
return false;
}
if (next() != other.next()) {
return false;
}
} else {
return ! other.hasNext();
}
}
}
开发者ID:wildfly,项目名称:wildfly-common,代码行数:24,代码来源:ByteIterator.java
示例10: addFileAsAttachment
import org.wildfly.common.Assert; //导入依赖的package包/类
/**
* Associate a file with the operation. This will create a {@code FileInputStream}
* and add it as attachment.
*
* @param file the file
* @return the operation builder
*/
public OperationBuilder addFileAsAttachment(final Path file) {
Assert.checkNotNullParam("file", file);
try {
FileStreamEntry entry = new FileStreamEntry(file);
if (inputStreams == null) {
inputStreams = new ArrayList<InputStream>();
}
inputStreams.add(entry);
} catch (IOException e) {
throw new RuntimeException(e);
}
return this;
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:OperationBuilder.java
示例11: chain
import org.wildfly.common.Assert; //导入依赖的package包/类
/**
* Principal transformer which transforms original principal by first transformer
* in chain, its output transforms by second transformer etc. Output of last
* transformer is returned.
*/
static PrincipalTransformer chain(PrincipalTransformer... transformers) {
Assert.checkNotNullParam("transformers", transformers);
final PrincipalTransformer[] clone = transformers.clone();
for (int i = 0; i < clone.length; i++) {
Assert.checkNotNullArrayParam("transformers", i, clone[i]);
}
return principal -> {
for (PrincipalTransformer transformer : clone) {
if (principal == null) return null;
principal = transformer.apply(principal);
}
return principal;
};
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:PrincipalTransformer.java
示例12: matches
import org.wildfly.common.Assert; //导入依赖的package包/类
/**
* Determine if this CIDR address matches the given address.
*
* @param address the address to test
* @return {@code true} if the address matches, {@code false} otherwise
*/
public boolean matches(InetAddress address) {
Assert.checkNotNullParam("address", address);
if (address instanceof Inet4Address) {
return matches((Inet4Address) address);
} else if (address instanceof Inet6Address) {
return matches((Inet6Address) address);
} else {
throw Assert.unreachableCode();
}
}
开发者ID:wildfly,项目名称:wildfly-common,代码行数:17,代码来源:CidrAddress.java
示例13: CredentialStoreUtility
import org.wildfly.common.Assert; //导入依赖的package包/类
/**
* Create Credential Store.
*
* @param credentialStoreFileName name of file to hold credentials
* @param storePassword master password (clear text) to open the credential store
* @param adminKeyPassword a password (clear text) for protecting admin key
* @param createStorageFirst flag whether to create storage first and then initialize Credential Store
*/
public CredentialStoreUtility(String credentialStoreFileName, String storePassword, String adminKeyPassword, boolean createStorageFirst) {
Assert.checkNotNullParam("credentialStoreFileName", credentialStoreFileName);
Assert.checkNotNullParam("storePassword", storePassword);
Assert.checkNotNullParam("adminKeyPassword", adminKeyPassword);
this.credentialStoreFileName = credentialStoreFileName;
try {
Map<String, String> attributes = new HashMap<>();
if (createStorageFirst) {
createKeyStore("JCEKS", storePassword.toCharArray());
}
credentialStore = CredentialStore.getInstance(KeyStoreCredentialStore.KEY_STORE_CREDENTIAL_STORE);
attributes.put("location", credentialStoreFileName);
attributes.put("keyStoreType", "JCEKS");
attributes.put("modifiable", "true");
if (!createStorageFirst) {
File storage = new File(credentialStoreFileName);
if (storage.exists()) {
storage.delete();
}
}
credentialStore.initialize(attributes, new CredentialStore.CredentialSourceProtectionParameter(
IdentityCredentials.NONE.withCredential(convertToPasswordCredential(storePassword.toCharArray()))
));
} catch (Throwable t) {
LOGGER.error(t);
throw new RuntimeException(t);
}
LOGGER.debugf("Credential Store created [%s] with master password \"%s\"", credentialStoreFileName, storePassword);
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:40,代码来源:CredentialStoreUtility.java
示例14: createMulticastSocket
import org.wildfly.common.Assert; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public MulticastSocket createMulticastSocket(String name, SocketAddress address) throws IOException {
Assert.checkNotNullParam("name", name);
Assert.checkNotNullParam("address", address);
return ManagedMulticastSocketBinding.create(name, this.namedRegistry, address);
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:8,代码来源:SocketBindingManagerImpl.java
示例15: create
import org.wildfly.common.Assert; //导入依赖的package包/类
public static StandaloneServer create(final File jbossHomeDir, final ModuleLoader moduleLoader, final Properties systemProps, final Map<String, String> systemEnv, final String[] cmdargs) {
Assert.checkNotNullParam("jbossHomeDir", jbossHomeDir);
Assert.checkNotNullParam("moduleLoader", moduleLoader);
Assert.checkNotNullParam("systemProps", systemProps);
Assert.checkNotNullParam("systemEnv", systemEnv);
Assert.checkNotNullParam("cmdargs", cmdargs);
setupCleanDirectories(jbossHomeDir.toPath(), systemProps);
return new StandaloneServerImpl(cmdargs, systemProps, systemEnv, moduleLoader);
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:EmbeddedStandaloneServerFactory.java
示例16: compareAddressBytesTo
import org.wildfly.common.Assert; //导入依赖的package包/类
public int compareAddressBytesTo(final byte[] otherBytes, final int otherNetmaskBits, final int scopeId) {
Assert.checkNotNullParam("bytes", otherBytes);
final int otherLength = otherBytes.length;
if (otherLength != 4 && otherLength != 16) {
throw CommonMessages.msg.invalidAddressBytes(otherLength);
}
// IPv4 before IPv6
final byte[] cachedBytes = this.cachedBytes;
int res = signum(cachedBytes.length - otherLength);
if (res != 0) return res;
res = signum(scopeId - getScopeId());
if (res != 0) return res;
// sorted numerically with long matches coming later
final int netmaskBits = this.netmaskBits;
int commonPrefix = min(netmaskBits, otherNetmaskBits);
// compare byte-wise as far as we can
int i = 0;
while (commonPrefix >= 8) {
res = signum((cachedBytes[i] & 0xff) - (otherBytes[i] & 0xff));
if (res != 0) return res;
i++;
commonPrefix -= 8;
}
while (commonPrefix > 0) {
final int bit = 1 << commonPrefix;
res = signum((cachedBytes[i] & bit) - (otherBytes[i] & bit));
if (res != 0) return res;
commonPrefix--;
}
// common prefix is a match; now the shortest mask wins
return signum(netmaskBits - otherNetmaskBits);
}
开发者ID:wildfly,项目名称:wildfly-common,代码行数:33,代码来源:CidrAddress.java
示例17: andThen
import org.wildfly.common.Assert; //导入依赖的package包/类
default ExceptionConsumer<T, E> andThen(ExceptionConsumer<? super T, ? extends E> after) {
Assert.checkNotNullParam("after", after);
return t -> {
accept(t);
after.accept(t);
};
}
开发者ID:wildfly,项目名称:wildfly-common,代码行数:8,代码来源:ExceptionConsumer.java
示例18: compile
import org.wildfly.common.Assert; //导入依赖的package包/类
/**
* Compile an expression string.
*
* @param string the expression string (must not be {@code null})
* @param flags optional flags to apply which affect the compilation (must not be {@code null})
* @return the compiled expression (not {@code null})
*/
public static Expression compile(String string, EnumSet<Flag> flags) {
Assert.checkNotNullParam("string", string);
Assert.checkNotNullParam("flags", flags);
final Node content;
final Itr itr;
if (flags.contains(Flag.NO_TRIM)) {
itr = new Itr(string);
} else {
itr = new Itr(string.trim());
}
content = parseString(itr, true, false, false, flags);
return content == Node.NULL ? EMPTY : new Expression(content);
}
开发者ID:wildfly,项目名称:wildfly-common,代码行数:21,代码来源:Expression.java
示例19: addOptions
import org.wildfly.common.Assert; //导入依赖的package包/类
public void addOptions(JvmElement jvmElement, List<String> command){
Assert.checkNotNullParam("jvmElement", jvmElement);
Assert.checkNotNullParam("command", command);
JvmOptionsBuilder builder = BUILDERS.get(jvmElement.getJvmType());
if (builder == null) {
throw HostControllerLogger.ROOT_LOGGER.unknown("jvm", jvmElement.getJvmType());
}
builder.addToOptions(jvmElement, command);
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:10,代码来源:JvmOptionsBuilderFactory.java
示例20: getAddOperation
import org.wildfly.common.Assert; //导入依赖的package包/类
static ModelNode getAddOperation(final String connectionName, final String uri, PathAddress address) {
Assert.checkNotNullParam("connectionName", connectionName);
Assert.checkNotEmptyParam("connectionName", connectionName);
Assert.checkNotNullParam("uri", uri);
Assert.checkNotEmptyParam("uri", uri);
final ModelNode addOperation = new ModelNode();
addOperation.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
addOperation.get(ModelDescriptionConstants.OP_ADDR).set(address.toModelNode());
// set the other params
addOperation.get(CommonAttributes.URI).set(uri);
return addOperation;
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:15,代码来源:GenericOutboundConnectionAdd.java
注:本文中的org.wildfly.common.Assert类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论