Home | History | Annotate | Download | only in item
      1 /*
      2  * Copyright (C) 2017 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.loganalysis.item;
     17 
     18 import java.util.Arrays;
     19 import java.util.HashSet;
     20 import java.util.Set;
     21 
     22 /** An {@link IItem} used to store an app's version code and name. */
     23 public class AppVersionItem extends GenericItem {
     24 
     25     /** Constants for JSON output */
     26     public static final String VERSION_CODE = "VERSION_CODE";
     27 
     28     public static final String VERSION_NAME = "VERSION_NAME";
     29 
     30     private static final Set<String> ATTRIBUTES =
     31             new HashSet<String>(Arrays.asList(VERSION_CODE, VERSION_NAME));
     32 
     33     /**
     34      * The constructor for {@link AppVersionItem}
     35      *
     36      * @param versionCode the version code
     37      * @param versionName the version name
     38      */
     39     public AppVersionItem(int versionCode, String versionName) {
     40         super(ATTRIBUTES);
     41 
     42         setAttribute(VERSION_CODE, versionCode);
     43         setAttribute(VERSION_NAME, versionName);
     44     }
     45 
     46     public int getVersionCode() {
     47         return (Integer) getAttribute(VERSION_CODE);
     48     }
     49 
     50     public String getVersionName() {
     51         return (String) getAttribute(VERSION_NAME);
     52     }
     53 }
     54