Skip to main content
summaryrefslogtreecommitdiffstats
blob: 3c39127bd59be47445304034512491d328adca6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
 * Copyright (c) 2013 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.framework.core.data;

import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.eclipse.osee.framework.jdk.core.type.BaseId;
import org.eclipse.osee.framework.jdk.core.type.Id;
import org.eclipse.osee.framework.jdk.core.type.IdSerializer;
import org.eclipse.osee.framework.jdk.core.type.Identifiable;

/**
 * @author Megumi Telles
 */
@JsonSerialize(using = IdSerializer.class)
public interface ArtifactId extends Identifiable<String>, Id {

   public static final ArtifactId SENTINEL = ArtifactId.valueOf(Id.SENTINEL);

   default Long getUuid() {
      return getId();
   }

   public static ArtifactId valueOf(String id) {

      return valueOf(Long.valueOf(id));
   }

   @JsonCreator
   public static ArtifactId valueOf(long id) {
      final class ArtifactIdImpl extends BaseId implements ArtifactId {
         public ArtifactIdImpl(Long artId) {
            super(artId);
         }

         @Override
         public String getGuid() {
            return null;
         }

         @Override
         public String getName() {
            return null;
         }
      }
      return new ArtifactIdImpl(id);
   }

   default String toStringWithId() {
      return String.format("[%s][%s]", getName(), getUuid());
   }

   @Override
   default Long getId() {
      return getUuid();
   }
}

Back to the top