All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gh.bmd.jrt.android.routine.DefaultServiceRoutineBuilder Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
/*
 * 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 com.gh.bmd.jrt.android.routine;

import android.content.Context;
import android.os.Looper;

import com.gh.bmd.jrt.android.builder.ServiceRoutineBuilder;
import com.gh.bmd.jrt.android.invocation.AndroidInvocation;
import com.gh.bmd.jrt.android.service.RoutineService;
import com.gh.bmd.jrt.builder.RoutineConfiguration;
import com.gh.bmd.jrt.builder.TemplateRoutineBuilder;
import com.gh.bmd.jrt.common.ClassToken;
import com.gh.bmd.jrt.log.Log;
import com.gh.bmd.jrt.routine.Routine;
import com.gh.bmd.jrt.runner.Runner;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * Class implementing a builder of routine objects based on an invocation class token.
 * 

* Created by davide on 1/8/15. * * @param the input data type. * @param the output data type. */ class DefaultServiceRoutineBuilder extends TemplateRoutineBuilder implements ServiceRoutineBuilder { private final Context mContext; private final Class> mInvocationClass; private Class mLogClass; private Looper mLooper; private Class mRunnerClass; private Class mServiceClass; /** * Constructor. * * @param context the routine context. * @param classToken the invocation class token. * @throws java.lang.NullPointerException if the context or the class token are null. */ @SuppressWarnings("ConstantConditions") DefaultServiceRoutineBuilder(@Nonnull final Context context, @Nonnull final ClassToken> classToken) { if (context == null) { throw new NullPointerException("the context must not be null"); } mContext = context; mInvocationClass = classToken.getRawClass(); } @Nonnull public Routine buildRoutine() { return new ServiceRoutine(mContext, mServiceClass, mInvocationClass, getConfiguration(), mLooper, mRunnerClass, mLogClass); } @Nonnull public ServiceRoutineBuilder dispatchingOn(@Nullable final Looper looper) { mLooper = looper; return this; } @Nonnull public ServiceRoutineBuilder withLogClass( @Nullable final Class logClass) { mLogClass = logClass; return this; } @Nonnull public ServiceRoutineBuilder withRunnerClass( @Nullable final Class runnerClass) { mRunnerClass = runnerClass; return this; } @Nonnull public ServiceRoutineBuilder withServiceClass( @Nullable final Class serviceClass) { mServiceClass = serviceClass; return this; } @Nonnull @Override public ServiceRoutineBuilder withConfiguration( @Nullable final RoutineConfiguration configuration) { super.withConfiguration(configuration); return this; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy