Loading android/paths.go +7 −11 Original line number Diff line number Diff line Loading @@ -263,27 +263,23 @@ func ResPathWithName(ctx ModuleOutPathContext, p Path, name string) ModuleResPat // OptionalPath is a container that may or may not contain a valid Path. type OptionalPath struct { valid bool path Path path Path // nil if invalid. } // OptionalPathForPath returns an OptionalPath containing the path. func OptionalPathForPath(path Path) OptionalPath { if path == nil { return OptionalPath{} } return OptionalPath{valid: true, path: path} return OptionalPath{path: path} } // Valid returns whether there is a valid path func (p OptionalPath) Valid() bool { return p.valid return p.path != nil } // Path returns the Path embedded in this OptionalPath. You must be sure that // there is a valid path, since this method will panic if there is not. func (p OptionalPath) Path() Path { if !p.valid { if p.path == nil { panic("Requesting an invalid path") } return p.path Loading @@ -294,7 +290,7 @@ func (p OptionalPath) Path() Path { // It returns nil if this is not valid, or a single length slice containing the Path embedded in // this OptionalPath. func (p OptionalPath) AsPaths() Paths { if !p.valid { if p.path == nil { return nil } return Paths{p.path} Loading @@ -303,7 +299,7 @@ func (p OptionalPath) AsPaths() Paths { // RelativeToTop returns an OptionalPath with the path that was embedded having been replaced by the // result of calling Path.RelativeToTop on it. func (p OptionalPath) RelativeToTop() OptionalPath { if !p.valid { if p.path == nil { return p } p.path = p.path.RelativeToTop() Loading @@ -312,7 +308,7 @@ func (p OptionalPath) RelativeToTop() OptionalPath { // String returns the string version of the Path, or "" if it isn't valid. func (p OptionalPath) String() string { if p.valid { if p.path != nil { return p.path.String() } else { return "" Loading Loading
android/paths.go +7 −11 Original line number Diff line number Diff line Loading @@ -263,27 +263,23 @@ func ResPathWithName(ctx ModuleOutPathContext, p Path, name string) ModuleResPat // OptionalPath is a container that may or may not contain a valid Path. type OptionalPath struct { valid bool path Path path Path // nil if invalid. } // OptionalPathForPath returns an OptionalPath containing the path. func OptionalPathForPath(path Path) OptionalPath { if path == nil { return OptionalPath{} } return OptionalPath{valid: true, path: path} return OptionalPath{path: path} } // Valid returns whether there is a valid path func (p OptionalPath) Valid() bool { return p.valid return p.path != nil } // Path returns the Path embedded in this OptionalPath. You must be sure that // there is a valid path, since this method will panic if there is not. func (p OptionalPath) Path() Path { if !p.valid { if p.path == nil { panic("Requesting an invalid path") } return p.path Loading @@ -294,7 +290,7 @@ func (p OptionalPath) Path() Path { // It returns nil if this is not valid, or a single length slice containing the Path embedded in // this OptionalPath. func (p OptionalPath) AsPaths() Paths { if !p.valid { if p.path == nil { return nil } return Paths{p.path} Loading @@ -303,7 +299,7 @@ func (p OptionalPath) AsPaths() Paths { // RelativeToTop returns an OptionalPath with the path that was embedded having been replaced by the // result of calling Path.RelativeToTop on it. func (p OptionalPath) RelativeToTop() OptionalPath { if !p.valid { if p.path == nil { return p } p.path = p.path.RelativeToTop() Loading @@ -312,7 +308,7 @@ func (p OptionalPath) RelativeToTop() OptionalPath { // String returns the string version of the Path, or "" if it isn't valid. func (p OptionalPath) String() string { if p.valid { if p.path != nil { return p.path.String() } else { return "" Loading