1 /* 2 * Copyright 2016, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.managedprovisioning.preprovisioning.terms; 17 18 import static com.android.internal.util.Preconditions.checkStringNotEmpty; 19 20 import com.android.managedprovisioning.common.ProvisionLogger; 21 22 /** 23 * Class responsible for storing disclaimers 24 */ 25 public final class TermsDocument { 26 private final String mHeading; 27 private final String mContent; 28 29 /** 30 * Creates a {@link TermsDocument} instance. 31 * 32 * @param heading non-empty {@link String} 33 * @param content non-empty {@link String} 34 * @return null if either of the invocation arguments is an empty string 35 */ createInstance(String heading, String content)36 public static TermsDocument createInstance(String heading, String content) { 37 try { 38 return new TermsDocument(heading, content); 39 } catch (IllegalArgumentException e) { 40 ProvisionLogger.loge("Failed to parse a disclaimer.", e); 41 return null; 42 } 43 } 44 TermsDocument(String heading, String content)45 private TermsDocument(String heading, String content) { 46 mHeading = checkStringNotEmpty(heading); 47 mContent = checkStringNotEmpty(content); 48 } 49 50 /** @return Document heading */ getHeading()51 public String getHeading() { 52 return mHeading; 53 } 54 55 /** @return Document raw HTML content */ getContent()56 public String getContent() { 57 return mContent; 58 } 59 }