Added missing license headers to Java files
[platform/upstream/iotivity.git] / service / easy-setup / sdk / mediator / android / EasySetupCore / src / main / java / org / iotivity / service / easysetup / impl / EnrolleeDeviceFactory.java
1 /**
2  * ***************************************************************
3  * <p>
4  * Copyright 2015 Samsung Electronics All Rights Reserved.
5  * <p>
6  * <p>
7  * <p>
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * <p>
12  * http://www.apache.org/licenses/LICENSE-2.0
13  * <p>
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * <p>
20  * ****************************************************************
21  */
22
23 package org.iotivity.service.easysetup.impl;
24
25 import org.iotivity.service.easysetup.core.EnrolleeDevice;
26 import org.iotivity.service.easysetup.core.OnBoardingConfig;
27 import org.iotivity.service.easysetup.core.ProvisioningConfig;
28
29 import android.content.Context;
30
31 /**
32  * This a factory class provides the native implementation of the various Enrollee devices.
33  * Application can make use of Enrollee factory if it does not want to create its own Enrollee devices.
34  */
35 public class EnrolleeDeviceFactory {
36
37     Context mContext;
38
39     /**
40      * This method create & returns instance of EnrolleeDeviceFactory
41      *
42      * @param context This is Android Application context
43      */
44     public static EnrolleeDeviceFactory newInstance(Context context) {
45         return new EnrolleeDeviceFactory(context);
46     }
47
48     private EnrolleeDeviceFactory(Context context) {
49         mContext = context;
50     }
51
52     /**
53      * This method create & returns instance of Enrollee device of supported configuration
54      *
55      * @param onboardingConfig Contains details about the connectivity to be established between the Enrollee device & Mediator device in order to perform on-boarding
56      * @param provConfig       Contains details about the network to which Enrollee device is going to connect.
57      * @return Instance of the Enrollee device created natively.
58      */
59
60     public EnrolleeDevice newEnrolleeDevice(OnBoardingConfig onboardingConfig, ProvisioningConfig provConfig) {
61
62         EnrolleeDevice enrolleeDevice;
63
64         if (onboardingConfig.getConnType() == OnBoardingConfig.ConnType.WiFi) {
65             enrolleeDevice = new EnrolleeDeviceWiFiOnboarding(mContext, onboardingConfig, provConfig);
66         } else {
67             throw new IllegalArgumentException("OnBoarding configuration is not supported");
68         }
69
70         return enrolleeDevice;
71     }
72
73 }