Skip to content

Commit

Permalink
Made default implementations private
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoboss committed Feb 12, 2024
1 parent 74d0414 commit 9cf0bb4
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 55 deletions.
3 changes: 0 additions & 3 deletions lib/kiota_abstractions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ part 'src/api_client_builder.dart';
part 'src/base_request_builder.dart';
part 'src/date_only.dart';
part 'src/error_mappings.dart';
part 'src/date_only_impl.dart';
part 'src/extensions/date_only_extensions.dart';
part 'src/extensions/map_extensions.dart';
part 'src/extensions/request_information_extensions.dart';
part 'src/http_headers.dart';
part 'src/extensions/time_only_extensions.dart';
part 'src/http_headers.dart';
part 'src/http_method.dart';
Expand All @@ -46,4 +44,3 @@ part 'src/serialization/serialization_writer.dart';
part 'src/serialization/serialization_writer_factory.dart';
part 'src/serialization/serialization_writer_factory_registry.dart';
part 'src/time_only.dart';
part 'src/time_only_impl.dart';
27 changes: 22 additions & 5 deletions lib/src/date_only.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ part of '../kiota_abstractions.dart';
///
/// It can only be used to represent a date in the Gregorian calendar.
abstract class DateOnly {
/// Extracts the date part of a [DateTime] and creates a new [DateOnlyImpl].
/// Extracts the date part of a [DateTime] and creates a new [_DateOnlyImpl].
factory DateOnly.fromDateTime(DateTime dateTime) {
return DateOnlyImpl(
return _DateOnlyImpl(
day: dateTime.day,
month: dateTime.month,
year: dateTime.year,
);
}

/// This factory uses the [DateTime.parse] method to create a new
/// [DateOnlyImpl] instance from a string.
/// [_DateOnlyImpl] instance from a string.
factory DateOnly.fromDateTimeString(String dateTimeString) {
final date = DateTime.parse(dateTimeString);

return DateOnly.fromDateTime(date);
}

/// Creates a new [DateOnlyImpl] instance from the provided components.
/// Creates a new [_DateOnlyImpl] instance from the provided components.
factory DateOnly.fromComponents(
int year, [
int month = 1,
int day = 1,
]) {
return DateOnlyImpl(
return _DateOnlyImpl(
day: day,
month: month,
year: year,
Expand All @@ -47,3 +47,20 @@ abstract class DateOnly {
/// Gets the day of the date.
int get day;
}

class _DateOnlyImpl implements DateOnly {
_DateOnlyImpl({
required this.day,
required this.month,
required this.year,
});

@override
final int day;

@override
final int month;

@override
final int year;
}
19 changes: 0 additions & 19 deletions lib/src/date_only_impl.dart

This file was deleted.

31 changes: 26 additions & 5 deletions lib/src/time_only.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ part of '../kiota_abstractions.dart';
/// It is used to represent time only values in a serialization format agnostic
/// way.
abstract class TimeOnly {
/// Extracts the time part of a [DateTime] and creates a new [TimeOnlyImpl].
/// Extracts the time part of a [DateTime] and creates a new [_TimeOnlyImpl].
factory TimeOnly.fromDateTime(DateTime dateTime) {
return TimeOnlyImpl(
return _TimeOnlyImpl(
hours: dateTime.hour,
minutes: dateTime.minute,
seconds: dateTime.second,
Expand All @@ -17,21 +17,21 @@ abstract class TimeOnly {
}

/// This factory uses the [DateTime.parse] method to create a new
/// [TimeOnlyImpl] instance from a string.
/// [_TimeOnlyImpl] instance from a string.
factory TimeOnly.fromDateTimeString(String dateTimeString) {
final dateTime = DateTime.parse(dateTimeString);

return TimeOnly.fromDateTime(dateTime);
}

/// Constructs a new [TimeOnlyImpl] instance from the provided components.
/// Constructs a new [_TimeOnlyImpl] instance from the provided components.
factory TimeOnly.fromComponents(
int hours,
int minutes, [
int seconds = 0,
int milliseconds = 0,
]) {
return TimeOnlyImpl(
return _TimeOnlyImpl(
hours: hours,
minutes: minutes,
seconds: seconds,
Expand All @@ -51,3 +51,24 @@ abstract class TimeOnly {
/// Gets the milliseconds of the time.
int get milliseconds;
}

class _TimeOnlyImpl implements TimeOnly {
_TimeOnlyImpl({
required this.hours,
required this.minutes,
required this.seconds,
required this.milliseconds,
});

@override
final int hours;

@override
final int minutes;

@override
final int seconds;

@override
final int milliseconds;
}
23 changes: 0 additions & 23 deletions lib/src/time_only_impl.dart

This file was deleted.

0 comments on commit 9cf0bb4

Please sign in to comment.