Line data Source code
1 : // Copyright (C) 2012 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.project; 16 : 17 : import com.google.gerrit.entities.Project; 18 : import com.google.gerrit.extensions.restapi.RestResource; 19 : import com.google.gerrit.extensions.restapi.RestView; 20 : import com.google.gerrit.server.CurrentUser; 21 : import com.google.inject.TypeLiteral; 22 : 23 : public class ProjectResource implements RestResource { 24 152 : public static final TypeLiteral<RestView<ProjectResource>> PROJECT_KIND = new TypeLiteral<>() {}; 25 : 26 : private final ProjectState projectState; 27 : private final CurrentUser user; 28 : 29 144 : public ProjectResource(ProjectState projectState, CurrentUser user) { 30 144 : this.projectState = projectState; 31 144 : this.user = user; 32 144 : } 33 : 34 0 : ProjectResource(ProjectResource rsrc) { 35 0 : this.projectState = rsrc.getProjectState(); 36 0 : this.user = rsrc.getUser(); 37 0 : } 38 : 39 : public String getName() { 40 30 : return projectState.getName(); 41 : } 42 : 43 : public Project.NameKey getNameKey() { 44 144 : return projectState.getNameKey(); 45 : } 46 : 47 : public ProjectState getProjectState() { 48 76 : return projectState; 49 : } 50 : 51 : public CurrentUser getUser() { 52 30 : return user; 53 : } 54 : }