1
0
mirror of https://github.com/chylex/Code-Statistics.git synced 2024-11-24 12:42:46 +01:00
Code-Statistics/LanguageJava/Elements/Member.cs
2016-09-05 15:37:05 +02:00

36 lines
1.2 KiB
C#

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace LanguageJava.Elements{
public class Member{
public readonly ReadOnlyCollection<Annotation> Annotations;
public readonly Modifiers Modifiers;
public Member(List<Annotation> annotations, IEnumerable<Modifiers> modifiers){
this.Annotations = annotations.AsReadOnly();
this.Modifiers = modifiers.Aggregate(Modifiers.None, (acc, modifier) => acc | modifier);
}
public Member(Member source, Modifiers newModifiers){
this.Annotations = source.Annotations;
this.Modifiers = newModifiers;
}
protected Member(Member source){
this.Annotations = source.Annotations;
this.Modifiers = source.Modifiers;
}
public override string ToString(){
string memberStr = Annotations.Aggregate("", (str, annotation) => str+annotation.ToString()+' ');
foreach(Modifiers modifier in JavaModifiers.Values){
if (Modifiers.HasFlag(modifier))memberStr += JavaModifiers.ToString(modifier)+' ';
}
return memberStr;
}
}
}