1 /* 2 * Copyright (C) 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 17 public final class Derived extends Base { Derived()18 public Derived() { 19 this(0); 20 } 21 Derived(int intValue)22 public Derived(int intValue) { 23 super(intValue); 24 } 25 Derived(String stringValue)26 public Derived(String stringValue) { 27 super(stringValue); 28 stringField = null; // Clear field set by Base.<init>(String). 29 } 30 Derived(double doubleValue)31 public Derived(double doubleValue) { 32 super(doubleValue, null); 33 } 34 Derived(int intValue, double doubleValue, Object objectValue)35 public Derived(int intValue, double doubleValue, Object objectValue) { 36 super(intValue, doubleValue, objectValue); 37 objectField = null; // Clear field set by Base.<init>(int, double, Object). 38 intField = 0; // Clear field set by Base.<init>(int, double, Object). 39 } 40 Derived(int intValue, double doubleValue, Object objectValue, String stringValue)41 Derived(int intValue, double doubleValue, Object objectValue, String stringValue) { 42 super(intValue, doubleValue, objectValue, stringValue); 43 // Clearing fields here doesn't help because the superclass constructor must 44 // satisfy the pattern constraints on its own and it doesn't (it has 4 IPUTs). 45 intField = 0; 46 doubleField = 0.0; 47 objectField = null; 48 stringField = null; 49 } 50 Derived(float floatValue)51 public Derived(float floatValue) { 52 super(); 53 floatField = floatValue; 54 } 55 Derived(int intValue, double doubleValue, Object objectValue, float floatValue)56 public Derived(int intValue, double doubleValue, Object objectValue, float floatValue) { 57 super(intValue, doubleValue, objectValue); 58 objectField = null; // Clear field set by Base.<init>(int, double, Object). 59 floatField = floatValue; 60 } 61 62 public float floatField; 63 } 64