View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.model.meta;
17  
18  
19  
20  
21  import org.fourthline.cling.model.Validatable;
22  import org.fourthline.cling.model.ValidationError;
23  
24  import java.util.List;
25  import java.util.ArrayList;
26  
27  /**
28   * Version of the UPnP Device Architecture (UDA), defaults to 1.0.
29   *
30   * @author Christian Bauer
31   */
32  public class UDAVersion implements Validatable {
33      
34      private int major = 1;
35      private int minor = 0;
36  
37      public UDAVersion() {
38      }
39  
40      public UDAVersion(int major, int minor) {
41          this.major = major;
42          this.minor = minor;
43      }
44  
45      public int getMajor() {
46          return major;
47      }
48  
49      public int getMinor() {
50          return minor;
51      }
52  
53      public List<ValidationError> validate() {
54          List<ValidationError> errors = new ArrayList<>();
55  
56          if (getMajor() != 1) {
57              errors.add(new ValidationError(
58                      getClass(),
59                      "major",
60                      "UDA major spec version must be 1"
61              ));
62          }
63          if (getMajor() < 0) {
64              errors.add(new ValidationError(
65                      getClass(),
66                      "minor",
67                      "UDA minor spec version must be equal or greater 0"
68              ));
69          }
70  
71          return errors;
72      }
73  }