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 JRoutine_${interfaceName}${genericTypes} implements ${interfaceFullName} {
private final String mShareGroup;
private final java.lang.ref.WeakReference<${classFullName}> mWrapped;
@SuppressWarnings("ConstantConditions")
public JRoutine_${interfaceName}(@javax.annotation.Nonnull final ${classFullName} wrapped,
final String shareGroup, 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.Share.ALL;
${routineFieldsInit}
}
@javax.annotation.Nonnull
public static ${genericTypes} com.gh.bmd.jrt.processor.builder.WrapperBuilder<${interfaceFullName}> on(final ${classFullName} wrapped) {
return new ${interfaceName}WrapperBuilder${genericTypes}(wrapped);
}
private Object getMutex(final String shareGroup) {
if (com.gh.bmd.jrt.annotation.Share.NONE.equals(shareGroup)) {
return null;
}
final String groupName = (shareGroup != null) ? shareGroup : mShareGroup;
return com.gh.bmd.jrt.builder.RoutineBuilders.getSharedMutex(mWrapped, groupName);
}
private static class ${interfaceName}WrapperBuilder${genericTypes} extends com.gh.bmd.jrt.processor.builder.AbstractWrapperBuilder<${interfaceFullName}> {
private final ${classFullName} mTarget;
private final com.gh.bmd.jrt.common.ClassToken<${interfaceFullName}> mToken = new com.gh.bmd.jrt.common.ClassToken<${interfaceFullName}>() {};
private ${interfaceName}WrapperBuilder(@javax.annotation.Nonnull final ${classFullName} target) {
mTarget = target;
}
@javax.annotation.Nonnull
@Override
protected com.gh.bmd.jrt.common.ClassToken<${interfaceFullName}> getInterfaceToken() {
return mToken;
}
@javax.annotation.Nonnull
@Override
protected Object getTarget() {
return mTarget;
}
@javax.annotation.Nonnull
@Override
protected ${interfaceFullName} newWrapper(
@javax.annotation.Nonnull final String shareGroup,
@javax.annotation.Nonnull final com.gh.bmd.jrt.builder.RoutineConfiguration configuration) {
return new JRoutine_${interfaceName}${genericTypes}(mTarget, shareGroup, configuration);
}
}