templates.header.txt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jroutine-processor Show documentation
Show all versions of jroutine-processor Show documentation
Parallel programming on the go
/*
* 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.
*/
// GENERATED CODE - PLEASE DO NOT EDIT
package ${packageName};
public final class ${classNamePrefix}${classNameSuffix}${genericTypes} implements ${interfaceFullName} {
private final String mShareGroup;
private final java.lang.ref.WeakReference<${classFullName}> mWrapped;
@SuppressWarnings("ConstantConditions")
public ${classNamePrefix}${classNameSuffix}(@javax.annotation.Nonnull final ${classFullName} wrapped,
@javax.annotation.Nullable final String shareGroup,
@javax.annotation.Nonnull final com.gh.bmd.jrt.builder.RoutineConfiguration configuration) {
if (wrapped == null) {
throw new NullPointerException("the wrapped instance must not be null");
}
mWrapped = new java.lang.ref.WeakReference<${classFullName}>(wrapped);
mShareGroup = (shareGroup != null) ? shareGroup : com.gh.bmd.jrt.annotation.ShareGroup.ALL;
${routineFieldsInit}
}
@javax.annotation.Nonnull
public static ${genericTypes} com.gh.bmd.jrt.proxy.builder.ProxyBuilder<${interfaceFullName}> on(@javax.annotation.Nonnull final ${classFullName} wrapped) {
return new ${classNameSuffix}ProxyBuilder${genericTypes}(wrapped);
}
@javax.annotation.Nullable
private Object getMutex(@javax.annotation.Nullable final String shareGroup) {
if (com.gh.bmd.jrt.annotation.ShareGroup.NONE.equals(shareGroup)) {
return null;
}
return com.gh.bmd.jrt.builder.RoutineBuilders.getSharedMutex(mWrapped, shareGroup);
}
private static class ${classNameSuffix}ProxyBuilder${genericTypes} extends com.gh.bmd.jrt.proxy.builder.AbstractProxyBuilder<${interfaceFullName}> {
private final ${classFullName} mTarget;
private final com.gh.bmd.jrt.common.ClassToken<${interfaceFullName}> mToken = new com.gh.bmd.jrt.common.ClassToken<${interfaceFullName}>() {};
@SuppressWarnings("ConstantConditions")
private ${classNameSuffix}ProxyBuilder(@javax.annotation.Nonnull final ${classFullName} target) {
if (target == null) {
throw new NullPointerException("the wrapped instance must not be null");
}
mTarget = target;
}
@Override
@javax.annotation.Nonnull
protected com.gh.bmd.jrt.common.ClassToken<${interfaceFullName}> getInterfaceToken() {
return mToken;
}
@Override
@javax.annotation.Nonnull
protected Object getTarget() {
return mTarget;
}
@Override
@javax.annotation.Nonnull
protected ${interfaceFullName} newProxy(
@javax.annotation.Nonnull final String shareGroup,
@javax.annotation.Nonnull final com.gh.bmd.jrt.builder.RoutineConfiguration configuration) {
return new ${classNamePrefix}${classNameSuffix}${genericTypes}(mTarget, shareGroup, configuration);
}
}