//
// Label.m
// GoToBus
//
// Created by iphone development on 6/4/14.
//
//

#import "Label.h"

@implementation Label

- (instancetype)init {
	self = [super init];
	if (self) {
		self.required = YES;
	}
	return self;
}

#pragma mark - Property

- (BOOL)optional {
	return !self.required;
}

- (void)setOptional:(BOOL)optional {
	self.required = !optional;
}

- (BOOL)post {
	return self.isTypeAsPassport;
}

- (BOOL)readonly {
	return self.post || self.isTypeAsPeopleBased || self.isTypeOfFlightInfo;
}

- (BOOL)isKindOfDate {
	return [self.alias isEqualToString:@"date"];
}

- (BOOL)isTypeAsPeopleBased {
	return [self.type isEqualToString:@"room_based"] || [self.type isEqualToString:@"ppl_based"];
}

- (BOOL)isTypeAsPassport {
	return [self.type isEqualToString:@"passport"] || [self.type isEqualToString:@"distinguish_passport"];
}

- (BOOL)isTypeOfFlightInfo {
	return [self.type isEqualToString:@"flight-info"];
}

- (BOOL)isTypeOfTextarea {
	return [self.type isEqualToString:@"textarea"];
}

- (BOOL)isKindAsStop {
	return [self.alias isEqualToString:@"departure"] || [self.alias isEqualToString:@"arrival"];
}

- (BOOL)isKindOfTime{
	return [self.type isEqualToString:@"time"];
}

-(BOOL)isTypeAsInput{
	return [self.type isEqualToString:@"input"] || [self.type isEqualToString:@"address"];
}

-(BOOL)isTypeOfText{
	return self.isTypeAsInput || self.isTypeOfTextarea;
}

@end
